import React, { useEffect, useState } from 'react';
import useStateRef from 'react-usestateref'
import { Button, Menu, Select, Collapse, Input, DatePicker, Table, Dropdown, Pagination, Space, Modal, Tag, Checkbox, notification, Spin, Popconfirm, Tooltip, Upload } from 'antd';
import { PlusOutlined, HeartTwoTone } from '@ant-design/icons';
import moment from "moment";
import http from "../request";
import { fieldGet, enSplit, exSplit, paramChange } from "../common/common";

import Column from "../components/Column";
import Header from "../components/Header";
import Store from "../components/Store";
import City from "../components/City";
import { BASE_URL, UPLOAD_URL } from "../request/api";
import { store } from "../store";
import Footer from "../components/Footer";
import Recycle from "../components/Recycle";
import ResizeableTitle from '../components/ResizableTitle';

const { Option } = Select;
const { RangePicker } = DatePicker;
const { TextArea } = Input;
const { Panel } = Collapse

const Client = () => {

    const field = { city: '=', region: '=', areas: '=', name: 'like', mobile: 'like', transaction: 'like', state: '=', purpose: '=', price: 'range', entrust: 'range', type: '=', area: 'range' }
    const houseField = { city: '=', region: '=', area: '=', estate_name: 'like', position: 'like', room_num: 'like', transaction: '=', purpose: '=', house_area: 'range' }
    const pagerDefault = { page: 1, pageSize: 10 }
    const columnDefault = [
        {
            title: '客源编号',
            dataIndex: 'number',
            width:80,
            key: 'number',
            checked: true,
            align: 'center',
            fixed: 'left',
            sorter: (a, b) => a.number - b.number,
        }, {
            title: '交易',
            dataIndex: 'transaction',
            width:80,
            key: 'transaction',
            checked: true,
            align: 'center',
            render: e => {
                if (e) {
                    if (e.search('求购') > -1) return <Tag color="red">求购</Tag>
                    if (e.search('求租') > -1) return <Tag color="green">求租</Tag>
                    if (e.search('租购') > -1) return <Tag color="blue">租购</Tag>
                }
                return ''
            },
            fixed: 'left',
            sorter: (a, b) => (a?.transaction ?? '').localeCompare((b?.transaction ?? ''), 'zh-CN'),
        }, {
            title: '委托日',
            dataIndex: 'entrust',
            width:80,
            key: 'entrust',
            checked: true,
            align: 'center',
            fixed: 'left',
            sorter: (a, b) => (a?.entrust ?? '').localeCompare((a?.entrust ?? ''), 'zh-CN'),
        }, {
            title: '客户',
            width:80,
            dataIndex: 'name',
            key: 'name',
            checked: true,
            align: 'center',
            fixed: 'left',
            sorter: (a, b) => (a?.name ?? '').localeCompare((b?.name ?? ''), 'zh-CN'),
        }, {
            title: '城区',
            dataIndex: 'city',
            width:80,
            key: 'city',
            checked: true,
            align: 'center',
            sorter: (a, b) => (a?.city + '' ?? '').localeCompare((b?.city + '' ?? ''), 'zh-CN'),
        }, {
            title: '片区',
            dataIndex: 'areas',
            key: 'areas',
            width:80,
            checked: true,
            align: 'center',
            sorter: (a, b) => (a?.areas + '' ?? '').localeCompare((b?.areas + '' ?? ''), 'zh-CN'),
        }, {
            title: '位置',
            width:80,
            dataIndex: 'address',
            key: 'address',
            checked: true,
            align: 'center',
            sorter: (a, b) => (a?.address ?? '').localeCompare((b?.address ?? ''), 'zh-CN'),
        }, {
            title: '楼层',
            width:80,
            dataIndex: 'floor',
            key: 'floor',
            checked: true,
            align: 'center',
            sorter: (a, b) => (a?.floor ?? '').localeCompare((b?.floor ?? ''), 'zh-CN'),
        }, {
            title: '房型',
            dataIndex: 'num_room',
            key: 'num_room',
            width:80,
            checked: true,
            align: 'center',
            sorter: (a, b) => a.num_room - b.num_room,
        }, {
            title: '面积',
            width:80,
            dataIndex: 'area',
            key: 'area',
            checked: true,
            align: 'center',
            sorter: (a, b) => parseInt(a.area ?? 0) - parseInt(b.area ?? 0),
        }, {
            title: '朝向',
            dataIndex: 'orientation',
            width:80,
            key: 'orientation',
            checked: true,
            align: 'center',
            sorter: (a, b) => (a?.orientation ?? '').localeCompare((b?.orientation ?? ''), 'zh-CN'),
        }, {
            title: '价格',
            dataIndex: 'price',
            key: 'price',
            width:80,
            checked: true,
            align: 'center',
            sorter: (a, b) => parseInt(a.price ?? 0) - parseInt(b.price ?? 0),
        }, {
            title: '装修',
            dataIndex: 'renovation',
            width:80,
            key: 'renovation',
            checked: true,
            align: 'center',
            sorter: (a, b) => (a?.renovation ?? '').localeCompare((b?.renovation ?? ''), 'zh-CN'),
        }, {
            title: '类型',
            dataIndex: 'type',
            width:80,
            key: 'type',
            checked: true,
            align: 'center',
            sorter: (a, b) => (a?.type ?? '').localeCompare((b?.type ?? ''), 'zh-CN'),
        }, {
            title: '员工',
            width:80,
            dataIndex: 'staff_id_one_data',
            key: 'staff_id_1',
            checked: true,
            align: 'center',
            render: e => e?.nickname ?? '',
            sorter: (a, b) => (a?.staff_id_one_data?.nickname ?? '').localeCompare((b?.staff_id_one_data?.nickname ?? ''), 'zh-CN'),
        }, {
            title: '部门',
            dataIndex: 'store_id_one_data',
            width:80,
            key: 'store_id_1',
            checked: true,
            align: 'center',
            render: e => e?.name ?? '',
            sorter: (a, b) => (a?.store_id_one_data?.name ?? '').localeCompare((b?.store_id_one_data?.name ?? ''), 'zh-CN'),
        }, {
            title: '最后跟进日',
            width:80,
            dataIndex: 'last_time',
            key: 'last_time',
            checked: true,
            align: 'center',
            sorter: (a, b) => (a?.last_time ?? '').localeCompare((b?.last_time ?? ''), 'zh-CN'),
        }, {
            title: '未跟进',
            dataIndex: 'how_days',
            width:80,
            key: 'how_days',
            checked: true,
            align: 'center',
            sorter: (a, b) => (a?.how_days ?? '').localeCompare((b?.how_days ?? ''), 'zh-CN'),
        }, {
            title: '操作',
            key: 'action',
            checked: true,
            align: 'center',
            render: e => (
                <Space size="middle">
                    <img className="u-btn" src={require('../assets/icon/icon-12.png').default} title="编辑" onClick={() => clientEdit(e.id)} alt="" />
                    <Popconfirm title="确定删除？" okText="确定" cancelText="取消" onConfirm={() => clientDel(e.id)}>
                        <img className="u-btn" src={require('../assets/icon/icon-13.png').default} alt="" title="删除" />
                    </Popconfirm>
                </Space>
            ),
        },
    ]
    const columnDefau = [
        {
            title: '客源编号',
            dataIndex: 'number',
            width:80,
            key: 'number',
            checked: true,
            align: 'center',
            fixed: 'left',
            sorter: (a, b) => a.number - b.number,
        }, {
            title: '交易',
            dataIndex: 'transaction',
            width:80,
            key: 'transaction',
            checked: true,
            align: 'center',
            render: e => {
                if (e) {
                    if (e.search('求购') > -1) return <Tag color="red">求购</Tag>
                    if (e.search('求租') > -1) return <Tag color="green">求租</Tag>
                    if (e.search('租购') > -1) return <Tag color="blue">租购</Tag>
                }
                return ''
            },
            fixed: 'left',
            sorter: (a, b) => (a?.transaction ?? '').localeCompare((b?.transaction ?? ''), 'zh-CN'),
        }, {
            title: '委托日',
            dataIndex: 'entrust',
            width:80,
            key: 'entrust',
            checked: true,
            align: 'center',
            fixed: 'left',
            sorter: (a, b) => (a?.entrust ?? '').localeCompare((a?.entrust ?? ''), 'zh-CN'),
        }, {
            title: '客户',
            dataIndex: 'name',
            width:80,
            key: 'name',
            checked: true,
            align: 'center',
            fixed: 'left',
            sorter: (a, b) => (a?.name ?? '').localeCompare((b?.name ?? ''), 'zh-CN'),
        }, {
            title: '城区',
            dataIndex: 'city',
            width:80,
            key: 'city',
            checked: true,
            align: 'center',
            sorter: (a, b) => (a?.city + '' ?? '').localeCompare((b?.city + '' ?? ''), 'zh-CN'),
        }, {
            title: '片区',
            dataIndex: 'areas',
            width:80,
            key: 'areas',
            checked: true,
            align: 'center',
            sorter: (a, b) => (a?.areas + '' ?? '').localeCompare((b?.areas + '' ?? ''), 'zh-CN'),
        }, {
            title: '位置',
            dataIndex: 'address',
            width:80,
            key: 'address',
            checked: true,
            align: 'center',
            sorter: (a, b) => (a?.address ?? '').localeCompare((b?.address ?? ''), 'zh-CN'),
        }, {
            title: '楼层',
            dataIndex: 'floor',
            width:80,
            key: 'floor',
            checked: true,
            align: 'center',
            sorter: (a, b) => (a?.floor ?? '').localeCompare((b?.floor ?? ''), 'zh-CN'),
        }, {
            title: '房型',
            dataIndex: 'num_room',
            width:80,
            key: 'num_room',
            checked: true,
            align: 'center',
            sorter: (a, b) => a.num_room - b.num_room,
        }, {
            title: '面积',
            width:80,
            dataIndex: 'area',
            key: 'area',
            checked: true,
            align: 'center',
            sorter: (a, b) => parseInt(a.area ?? 0) - parseInt(b.area ?? 0),
        }, {
            title: '朝向',
            dataIndex: 'orientation',
            width:80,
            key: 'orientation',
            checked: true,
            align: 'center',
            sorter: (a, b) => (a?.orientation ?? '').localeCompare((b?.orientation ?? ''), 'zh-CN'),
        }, {
            title: '价格',
            dataIndex: 'price',
            width:80,
            key: 'price',
            checked: true,
            align: 'center',
            sorter: (a, b) => parseInt(a.price ?? 0) - parseInt(b.price ?? 0),
        }, {
            title: '装修',
            dataIndex: 'renovation',
            width:80,
            key: 'renovation',
            checked: true,
            align: 'center',
            sorter: (a, b) => (a?.renovation ?? '').localeCompare((b?.renovation ?? ''), 'zh-CN'),
        }, {
            title: '配套',
            dataIndex: 'matching',
            width:80,
            key: 'matching',
            checked: true,
            align: 'center',
            sorter: (a, b) => (a?.matching ?? '').localeCompare((b?.matching ?? ''), 'zh-CN'),
        }, {
            title: '用途',
            dataIndex: 'purpose',
            width:80,
            key: 'purpose',
            checked: true,
            align: 'center',
            sorter: (a, b) => (a?.purpose ?? '').localeCompare((b?.purpose ?? ''), 'zh-CN'),
        }, {
            title: '类型',
            width:80,
            dataIndex: 'type',
            key: 'type',
            checked: true,
            align: 'center',
            sorter: (a, b) => (a?.type ?? '').localeCompare((b?.type ?? ''), 'zh-CN'),
        }, {
            title: '备注',
            dataIndex: 'memo',
            key: 'memo',
            width:80,
            checked: true,
            align: 'center',
            sorter: (a, b) => (a?.memo ?? '').localeCompare((b?.memo ?? ''), 'zh-CN'),
        }, {
            title: '等级',
            dataIndex: 'level',
            width:80,
            key: 'level',
            checked: true,
            align: 'center',
            sorter: (a, b) => (a?.level ?? '').localeCompare((b?.level ?? ''), 'zh-CN'),
        }, {
            title: '部门1',
            dataIndex: 'store_id_one_data',
            width:80,
            key: 'store_id_1',
            checked: true,
            align: 'center',
            render: e => e?.name ?? '',
            sorter: (a, b) => (a?.store_id_one_data?.name ?? '').localeCompare((b?.store_id_one_data?.name ?? ''), 'zh-CN'),
        }, {
            title: '员工',
            dataIndex: 'staff_id_one_data',
            key: 'staff_id_1',
            width:80,
            checked: true,
            align: 'center',
            render: e => e?.nickname ?? '',
            sorter: (a, b) => (a?.staff_id_one_data?.nickname ?? '').localeCompare((b?.staff_id_one_data?.nickname ?? ''), 'zh-CN'),
        }, {
            title: '部门2',
            dataIndex: 'store_id_two_data',
            key: 'store_id_2',
            checked: true,
            width:80,
            align: 'center',
            render: e => e?.name ?? '',
            sorter: (a, b) => (a?.store_id_two_data?.name ?? '').localeCompare((b?.store_id_two_data?.name ?? ''), 'zh-CN'),
        }, {
            title: '员工2',
            dataIndex: 'staff_id_two_data',
            width:80,
            key: 'staff_id_2',
            checked: true,
            align: 'center',
            render: e => e?.nickname ?? '',
            sorter: (a, b) => (a?.staff_id_two_data?.nickname ?? '').localeCompare((b?.staff_id_two_data?.nickname ?? ''), 'zh-CN'),
        }, {
            title: '状态',
            width:80,
            dataIndex: 'state',
            key: 'state',
            checked: true,
            align: 'center',
            sorter: (a, b) => (a?.state ?? '').localeCompare((b?.state ?? ''), 'zh-CN'),
        }, {
            title: '公私',
            dataIndex: 'is_private',
            key: 'is_private',
            width:80,
            checked: true,
            align: 'center',
            render: e => e ? '私客' : '公客',
            sorter: (a, b) => a.is_private - b.is_private,
            className: ((store.getState().staff?.customer?.skck?.value ?? '') === '无') ? 'no' : ''
        }, {
            title: '最后跟进日',
            dataIndex: 'last_time',
            width:80,
            key: 'last_time',
            checked: true,
            align: 'center',
            sorter: (a, b) => (a?.last_time ?? '').localeCompare((b?.last_time ?? ''), 'zh-CN'),
        }, {
            title: '未跟进',
            dataIndex: 'how_days',
            width:80,
            key: 'how_days',
            checked: true,
            align: 'center',
            sorter: (a, b) => (a?.how_days ?? '').localeCompare((b?.how_days ?? ''), 'zh-CN'),
        }, {
            title: '来源',
            dataIndex: 'source',
            width:80,
            key: 'source',
            checked: true,
            align: 'center',
            sorter: (a, b) => (a?.source ?? '').localeCompare((b?.source ?? ''), 'zh-CN'),
        }, {
            title: '类别',
            dataIndex: 'category',
            width:80,
            key: 'category',
            checked: true,
            align: 'center',
            sorter: (a, b) => (a?.category ?? '').localeCompare((b?.category ?? ''), 'zh-CN'),
        }, {
            title: '意向',
            dataIndex: 'objective',
            key: 'objective',
            width:80,
            checked: true,
            align: 'center',
            sorter: (a, b) => (a?.objective ?? '').localeCompare((b?.objective ?? ''), 'zh-CN'),
        }, {
            title: '期限',
            dataIndex: 'term',
            width:80,
            key: 'term',
            checked: true,
            align: 'center',
            sorter: (a, b) => (a?.term ?? '').localeCompare((b?.term ?? ''), 'zh-CN'),
        }, {
            title: '需求',
            // dataIndex: 'transaction',
            key: 'transaction',
            checked: true,
            width:80,
            align: 'center',
            render: e => e?.transaction?.split('-')[0] ?? '',
            sorter: (a, b) => (a?.transaction?.split('-')[0] ?? '').localeCompare((b?.transaction?.split('-')[0] ?? ''), 'zh-CN'),
        }, {
            title: '首付',
            dataIndex: 'one_payments',
            key: 'one_payments',
            width:80,
            checked: true,
            align: 'center',
            sorter: (a, b) => parseInt(a.one_payments ?? 0) - parseInt(b.one_payments ?? 0),
        }, {
            title: '月供',
            dataIndex: 'mon_supply',
            key: 'mon_supply',
            checked: true,
            width:80,
            align: 'center',
            sorter: (a, b) => parseInt(a.mon_supply ?? 0) - parseInt(b.mon_supply ?? 0),
        }, {
            title: '带看',
            checked: true,
            align: 'center',
            render: e => (
                <Space size="middle">
                    <Button type="primary" size="small" onClick={() => beltOpen(e, ['belt', '带'])}>记录</Button>
                    <Button type="primary" size="small" onClick={() => beltAdd(e, ['belt', '带'])}>添加</Button>
                </Space>
            )
        }, {
            title: '约看',
            checked: true,
            align: 'center',
            render: e => (
                <Space size="middle">
                    <Button type="primary" size="small" onClick={() => beltOpen(e, ['book', '约'])}>记录</Button>
                    <Button type="primary" size="small" onClick={() => beltAdd(e, ['book', '约'])}>添加</Button>
                </Space>
            )
        }, {
            title: '跟进',
            checked: true,
            align: 'center',
            render: e => (
                <Space size="middle">
                    <Button type="primary" size="small" onClick={() => followOpen(e)}>跟进</Button>
                </Space>
            )
        }, {
            title: '收藏',
            checked: true,
            align: 'center',
            render: e => (
                <Space size="middle">
                    <HeartTwoTone twoToneColor={e.guest_collect ? '#eb2f96' : '#999'} className="u-btn" onClick={() => collect(e)} />
                </Space>
            )
        }, {
            title: '操作',
            key: 'action',
            checked: true,
            align: 'center',
            render: e => (
                <Space size="middle">
                    <img className="u-btn" src={require('../assets/icon/icon-12.png').default} title="编辑" onClick={() => clientEdit(e.id)} alt="" />
                    <Popconfirm title="确定删除？" okText="确定" cancelText="取消" onConfirm={() => clientDel(e.id)}>
                        <img className="u-btn" src={require('../assets/icon/icon-13.png').default} alt="" title="删除" />
                    </Popconfirm>
                </Space>
            ),
        },
    ]

    let { customer } = { customer: undefined }
    if (store.getState().userInfo.group_id !== 3) {
        customer = store.getState().staff.customer
    }

    const [source, setSource] = useState([])
    const [column, setColumn] = useState([])
    const [param, setParam] = useState({})
    const [pager, setPager] = useState(pagerDefault)
    const [total, setTotal] = useState(0)
    const [select, setSelect] = useState([])

    const [client, setClient] = useState({ show: !1, text: '' })
    const [clientForm, setClientForm] = useState({})

    const [belt, setBelt] = useState({ show: !1, text: '' })
    const [beltType, setBeltType] = useState(['', ''])
    const [beltClient, setBeltClient] = useState({})
    const [beltForm, setBeltForm] = useState({})

    const [beltLog, setBeltLog] = useState({ show: !1 })
    const [beltLogSource, setBeltLogSource] = useState([])
    const [beltLogColumn] = useState([
        {
            title: '负责人',
            dataIndex: 'staff_data',
            render: e => e?.nickname ?? ''
        }, {
            title: '交易类型',
            dataIndex: 'pay_type',
        }, {
            title: '时间',
            dataIndex: 'time',
        }, {
            title: '会合地点',
            dataIndex: 'place',
            render: e => (
                <Tooltip title={e}>
                    <div className="u-line-1">{e}</div>
                </Tooltip>
            )
        }, {
            title: '操作',
            dataIndex: 'id',
            render: e => (
                <Space size="middle">
                    <img className="u-btn" src={require('../assets/icon/icon-12.png').default} alt="" title="编辑" onClick={() => beltEdit(e)} />
                    <Popconfirm title="确定删除？" okText="确定" cancelText="取消" onConfirm={() => beltDel(e)}>
                        <img className="u-btn" src={require('../assets/icon/icon-13.png').default} alt="" title="删除" />
                    </Popconfirm>
                </Space>
            )
        }
    ])
    const [beltLogPager, setBeltLogPager] = useState(pagerDefault)
    const [beltLogTotal, setBeltLogTotal] = useState(0)
    const [beltLogSelect, setBeltLogSelect] = useState([])

    const [houseSource, setHouseSource, houseSourceRef] = useStateRef([])
    const [houseColumn] = useState([
        {
            title: '类型',
            dataIndex: 'type',
            key: 'type'
        }, {
            title: '房源编号',
            dataIndex: 'house_number',
            key: 'house_number'
        }, {
            title: '交易',
            dataIndex: 'transaction',
            key: 'transaction'
        }, {
            title: '城区',
            dataIndex: 'region_data',
            key: 'region',
            render: e => e?.name ?? ''
        }, {
            title: '片区',
            dataIndex: 'area_data',
            key: 'area',
            render: e => e?.name ?? ''
        }, {
            title: '楼盘字典',
            dataIndex: 'estate_name',
            key: 'estate_name'
        }, {
            title: '栋座位置',
            dataIndex: 'position',
            key: 'position'
        }, {
            title: '房号',
            dataIndex: 'room_num',
            key: 'room_num'
        }, {
            title: '面积',
            dataIndex: 'house_area',
            key: 'house_area'
        }, {
            title: '用途',
            dataIndex: 'purpose',
            key: 'purpose'
        }, {
            title: '操作',
            dataIndex: 'id',
            key: 'id',
            render: e => <img className="u-btn" src={require('../../src/assets/icon/icon-13.png').default} onClick={() => houseDel(e)} alt="" title="删除" />
        }
    ])
    const [house, setHouse] = useState({ show: !1, text: '' })
    const [houseForm, setHouseForm] = useState({})
    const [houseList, setHouseList] = useState([])
    const [houseListColumn] = useState([
        {
            title: '类型',
            dataIndex: 'type',
        }, {
            title: '房源编号',
            dataIndex: 'house_number',
        }, {
            title: '交易',
            dataIndex: 'transaction',
        }, {
            title: '城区',
            dataIndex: 'region_data',
            render: e => e?.name ?? ''
        }, {
            title: '片区',
            dataIndex: 'area_data',
            render: e => e?.name ?? ''
        }, {
            title: '楼盘字典',
            dataIndex: 'estate_name',
        }, {
            title: '栋座位置',
            dataIndex: 'position',
        }, {
            title: '房号',
            dataIndex: 'room_num',
        }, {
            title: '面积',
            dataIndex: 'house_area',
        }, {
            title: '用途',
            dataIndex: 'purpose',
        }
    ])
    const [housePager, setHousePager] = useState(pagerDefault)
    const [houseTotal, setHouseTotal] = useState(0)
    const [houseSelect, setHouseSelect] = useState([])

    const [mask, setMask] = useState({ show: !1, text: '提交中...' })
    const [followData, setFollowData] = useState({})
    const [follow, setFollow] = useState({ show: !1 })
    const [followForm, setFollowForm] = useState({ is_remind: 1, state: 0 })

    const [fileList, setFileList] = useState([])
    const [preview, setPreview] = useState({ show: !1, content: '' })

    const uploadConfig = {
        name: "file",
        accept: 'image/*',
        fileList: fileList,
        listType: 'picture-card',
        action: UPLOAD_URL,
        headers: {
            token: store.getState().userInfo.token
        },
        onChange: ({ fileList }) => {
            setFileList(fileList)
        },
        onPreview: (file) => {
            setPreview({
                show: !0,
                content: BASE_URL + file.response.data.url
            })
        }
    }

    // 回收站-列
    const backColumns = [
        {
            title: '客源编号',
            dataIndex: 'number',
            key: 'number',
            checked: true,
        }, {
            title: '交易',
            dataIndex: 'transaction',
            key: 'transaction',
            checked: true,
            render: e => {
                if (e) {
                    if (e.search('求购') > -1) return <Tag color="red">求购</Tag>
                    if (e.search('求租') > -1) return <Tag color="green">求租</Tag>
                    if (e.search('租购') > -1) return <Tag color="blue">租购</Tag>
                }
                return ''
            }
        }, {
            title: '委托日',
            dataIndex: 'entrust',
            key: 'entrust',
            checked: true,
        }, {
            title: '客户',
            dataIndex: 'name',
            key: 'name',
            checked: true,
        }, {
            title: '位置',
            dataIndex: 'address',
            key: 'address',
            checked: true,
            render: e => (
                <Tooltip title={e}>
                    <div className="u-line-1" style={{ maxWidth: 150 }}>{e}</div>
                </Tooltip>
            )
        }, {
            title: '楼层',
            dataIndex: 'floor',
            key: 'floor',
            checked: true,
        }, {
            title: '房型',
            dataIndex: 'type',
            key: 'type',
            checked: true,
        }, {
            title: '面积',
            dataIndex: 'area',
            key: 'area',
            checked: true,
        }, {
            title: '朝向',
            dataIndex: 'orientation',
            key: 'orientation',
            checked: true,
        }, {
            title: '价格',
            dataIndex: 'price',
            key: 'price',
            checked: true,
        }, {
            title: '装修',
            dataIndex: 'renovation',
            key: 'renovation',
            checked: true,
        }, {
            title: '类型',
            dataIndex: 'type',
            key: 'type',
            checked: true,
        }, {
            title: '员工',
            dataIndex: 'staff_id_one_data',
            key: 'staff_id_1',
            checked: true,
            render: e => e?.nickname ?? ''
        }, {
            title: '部门',
            dataIndex: 'store_id_one_data',
            key: 'store_id_1',
            checked: true,
            render: e => e?.name ?? ''
        }, {
            title: '最后跟进日',
            dataIndex: 'last_time',
            key: 'last_time',
            checked: true,
        }, {
            title: '未跟进',
            dataIndex: 'how_days',
            key: 'how_days',
            checked: true,
        }
    ]

    // 房源跟进
    const [followShow, setFollowShow] = useState(!1)
    const [followSearch, setFollowSearch] = useState({})
    const [followPager, setFollowPager] = useState(pagerDefault)
    const [followTotal, setFollowTotal] = useState(0)
    const followColumn = [
        {
            title: '客户',
            align: 'center',
            render: e => e?.guest?.name ?? ''
        }, {
            title: '手机',
            align: 'center',
            render: e => e?.guest?.mobile ?? ''
        }, {
            title: '跟进方式',
            dataIndex: 'mode',
            align: 'center',
        }, {
            title: '员工',
            align: 'center',
            render: e => (e.store_data?.name ?? '') + '-' + (e.staff_data?.nickname ?? '')
        }, {
            title: '跟进类型',
            dataIndex: 'type',
            align: 'center',
        }, {
            title: '跟进内容',
            dataIndex: 'content',
            align: 'center',
            width: 150,
            render: e => (
                <Tooltip title={e}>
                    <div className="u-line-1" style={{ maxWidth: 150 }}>{e}</div>
                </Tooltip>
            )
        }, {
            title: '跟进图片',
            dataIndex: 'images',
            align: 'center',
            render: e => e && <img src={BASE_URL + e} onClick={() => setPreview({
                show: !0,
                content: BASE_URL + e
            })} alt="" className="u-btn" style={{ width: 50, height: 50, objectFit: 'contain' }} />
        }, {
            title: '跟进时间',
            dataIndex: 'time_text',
            align: 'center',
        }, {
            title: '提醒时间',
            dataIndex: 'remind',
            align: 'center',
        }, {
            title: '客源信息',
            align: 'center',
            render: e => <Button type="primary" size="small" onClick={() => clientEdit(e.guest_id)}>客源</Button>,
        }
    ]
    const followColumns = [...followColumn, {
        title: '操作',
        key: 'action',
        checked: true,
        render: e => (
            <Space size="middle">
                <Popconfirm title="确定删除？" okText="确定" cancelText="取消" onConfirm={() => followFunc.del(e.id)}>
                    <img className="u-btn" src={require('../assets/icon/icon-13.png').default} alt="" title="删除" />
                </Popconfirm>
            </Space>
        ),
    }]
    const [followSource, setFollowSource] = useState([])
    const [followSelect, setFollowSelect] = useState([])
    const followFunc = {
        list: () => {
            http('client.follow.index', {
                ...fieldGet(
                    { store_id: '=', staff_id: '=' },
                    followSearch,
                    followPager.page,
                    followPager.pageSize
                )
            }).then(res => {
                console.log(res);
                if (res.code === 1) {
                    setFollowSource(res.data.rows)
                    setFollowTotal(res.data.total)
                }
            })
        },
        reset: () => {
            setFollowSearch({})
            setFollowPager(pagerDefault)
        },
        del: (id) => {
            let ids = id > 0 ? [id] : followSelect
            if (!ids.length) {
                notification.error({
                    message: '请先选择'
                })
                return
            }
            if (!(customer?.gjsc_bb?.value ?? 1) && !(customer?.gjsc_kb?.value ?? 1)) return setjurisdiction(!0)
            if (!((customer?.gjsc_bb?.value ?? 1) && (customer?.gjsc_kb?.value ?? 1))) {
                const storeid = store.getState().userInfo.store_id
                // 判断本部
                if (customer?.gjsc_bb?.value ?? 1) {
                    const all = followSource.filter(i => {
                        for (let item of ids) {
                            if (i.id === item) {
                                if (i.follow_up_store_id === storeid) {
                                    return i.id
                                }
                            }
                        }
                    })
                    ids = all.map(i => i.id)
                }
                // 判断跨部
                if (customer?.gjsc_kb?.value ?? 1) {
                    const all = followSource.filter(i => {
                        for (let item of ids) {
                            if (i.id === item) {
                                if (i.follow_up_store_id !== storeid) {
                                    return i.id
                                }
                            }
                        }
                    })
                    ids = all.map(i => i.id)

                }
            }
            http('client.follow.del', { ids }).then(res => {
                if (res.code === 1) {
                    notification.success({
                        message: res.msg || '操作成功'
                    })
                } else {
                    notification.error({
                        message: res.msg || '操作失败，请重试'
                    })
                }
                followFunc.list()
            })
        },
        del2: (id) => {
            let ids = id > 0 ? [id] : followMsgSelect
            if (!ids.length) {
                notification.error({
                    message: '请先选择'
                })
                return
            }
            http('client.follow.del', { ids }).then(res => {
                if (res.code === 1) {
                    notification.success({
                        message: res.msg || '操作成功'
                    })
                } else {
                    notification.error({
                        message: res.msg || '操作失败，请重试'
                    })
                }
                followGet()
            })
        },
        staffChange: (store_id, staff_id) => {
            let newForm = { ...followSearch }
            newForm.store_id = store_id
            newForm.staff_id = staff_id
            setFollowSearch(newForm)
        },
        paramsChange: (name, value) => {
            let newForm = { ...followSearch }
            newForm[name] = value
            setFollowSearch(newForm)
        }
    }

    const [ope, setOpe] = useState({ show: !1, cur: 0 })
    const followMsgColumns = [
        {
            title: '跟进方式',
            dataIndex: 'mode',
            align: 'center',
        }, {
            title: '员工',
            align: 'center',
            render: e => (e.store_data?.name ?? '') + '-' + (e.staff_data?.nickname ?? '')
        }, {
            title: '跟进类型',
            dataIndex: 'type',
            align: 'center',
        }, {
            title: '跟进内容',
            dataIndex: 'content',
            align: 'center',
            width: 150,
            render: e => (
                <Tooltip title={e}>
                    <div className="u-line-1" style={{ maxWidth: 150 }}>{e}</div>
                </Tooltip>
            )
        }, {
            title: '跟进图片',
            dataIndex: 'images',
            align: 'center',
            render: e => e && <img src={BASE_URL + e} onClick={() => setPreview({
                show: !0,
                content: BASE_URL + e
            })} alt="" className="u-btn" style={{ width: 50, height: 50, objectFit: 'contain' }} />
        }, {
            title: '跟进时间',
            dataIndex: 'time_text',
            align: 'center',
        }, {
            title: '提醒时间',
            dataIndex: 'remind',
            align: 'center',
        }, {
            title: '操作',
            key: 'action',
            align: 'center',
            render: e => (
                <Space size="middle">
                    <Popconfirm title="确定删除？" okText="确定" cancelText="取消" onConfirm={() => followFunc.del(e.id)}>
                        <img className="u-btn" src={require('../assets/icon/icon-13.png').default} alt="" title="删除" />
                    </Popconfirm>
                </Space>
            ),
        },
    ]
    const [followList, setFollowList] = useState([])
    const [followMsgPager, setFollowMsgPager] = useState(pagerDefault)
    const [followMsgTotal, setFollowMsgTotal] = useState(0)
    const [followMsgSelect, setFollowMsgSelect] = useState([])

    const [show, setshow] = useState(!1)

    const [jurisdiction, setjurisdiction] = useState(!1)

    // 单击信息
    const [info, setinfo] = useState(null)

    const [isDropdown, setisDropdown] = useState(!1)

    const [ismessage, setismessage] = useState(!1)
    const [ismessage2, setismessage2] = useState(!1)

    const [change, setchange] = useState(!0)

    // 员工通讯录
    const [contacts, setcontacts] = useState(!1)
    // 通讯录内容
    const [contactsSource, setcontactsSource] = useState([])
    // 通讯录搜索请求字段
    const [staffSearch, setstaffSearch] = useState({})
    const [staffPager, setStaffPager] = useState({ page: 1, pageSize: 10 })
    const [staffTotal, setStaffTotal] = useState(0)

    // 部门信息
    const [allStore, setAllStore] = useState([])
    // 员工身份信息
    const [allAuth, setAllAuth] = useState([])

    // 通讯录表格配置项
    const contactsTable = [
        {
            title: '头像',
            checked: true,
            align: 'center',
            render: e => e?.avatar ?? 0 ? <img className="avatar" src={e.avatar} style={{ width: 60 }} alt="" /> : ''
        }, {
            title: '名称',
            checked: true,
            align: 'center',
            render: e => e?.username ?? ''
        }, {
            title: '性别',
            checked: true,
            align: 'center',
            render: e => (
                <Space size="middle">
                    {e?.gender === 1 ? <Tag color="blue">男</Tag> : <Tag color="red">女</Tag>}
                </Space>
            )
        }, {
            title: '职务',
            checked: true,
            align: 'center',
            render: e => e?.group?.name ?? ''
        }, {
            title: '电话',
            checked: true,
            align: 'center',
            render: e => e?.mobile ?? ''
        }, {
            title: '邮件',
            checked: true,
            align: 'center',
            render: e => e?.email ?? ''
        }, {
            title: '生日',
            checked: true,
            align: 'center',
            render: e => e?.birthday ?? ''
        }
    ]

    // 左键楼盘字典的菜单项
    const menu = (
        <Menu mode="vertical" onClick={() => setisDropdown(!1)}>
            <Menu.Item key='1' onClick={() => {
                paramChange(setParam, param, 'name', info?.name ?? '')
                setchange(!1)
                clientGet()
            }}>过滤[客户:{info?.name ?? ''}]</Menu.Item>
            <Menu.Item key='2' onClick={paramsReset}>清除所有过滤条件</Menu.Item>
            <Menu.Item key='3' onClick={() => beltAdd(info, ['book', '约'])}>新增约看</Menu.Item>
            <Menu.Item key='4' onClick={() => beltAdd(info, ['belt', '带'])}>新增带看</Menu.Item>
            <Menu.Item key='5' onClick={() => {
                setstaffSearch({
                    store_id: info?.staff_id_one_data?.store_id ?? '',
                    nickname: info?.staff_id_one_data?.nickname ?? ''
                })
                setcontacts(!0)
                }}>查找客源人[通讯录]</Menu.Item>
            <Menu.Item key='6' onClick={() => {
                paramsStaff(info?.store_id_one_data?.name ?? '', info?.staff_id_one_data?.nickname ?? '')
                clientGet()
            }}>快查[{info?.staff_id_one_data?.nickname ?? ''}]客源</Menu.Item>
            <Menu.Item key='7' onClick={() => {
                paramsStaff(info?.store_id_one_data?.name ?? '')
                clientGet()
            }}>快查[{info?.store_id_one_data?.name ?? ''}]客源</Menu.Item>
            {/* e.staff?.employee?.nickname ?? '' */}
            <Menu.Item key='8' onClick={() => collect(info)}>添加到客源收藏夹</Menu.Item>
            {/* <Menu.Item key='9'>置顶</Menu.Item> */}
        </Menu>
    );

    useEffect(() => {
        clientGet()
        // eslint-disable-next-line react-hooks/exhaustive-deps
    }, [pager])
    useEffect(() => {
        house.show && houseGet()
        // eslint-disable-next-line react-hooks/exhaustive-deps
    }, [house, housePager])
    useEffect(() => {
        beltLog.show && beltGet()
        // eslint-disable-next-line react-hooks/exhaustive-deps
    }, [beltLog, beltLogPager])
    useEffect(() => {
        !belt.show && beltReset()
        // eslint-disable-next-line react-hooks/exhaustive-deps
    }, [belt])
    useEffect(() => {
        ope.show && followGet()
        // eslint-disable-next-line react-hooks/exhaustive-deps
    }, [ope])
    useEffect(() => {
        !follow.show && followReset()
    }, [follow])
    useEffect(() => {
        followShow && followFunc.list()
        !followShow && followFunc.reset()
        // eslint-disable-next-line react-hooks/exhaustive-deps
    }, [followShow])
    useEffect(() => {
        followGet()
        // eslint-disable-next-line react-hooks/exhaustive-deps
    }, [followMsgPager])

    // 监听通讯录点击
    useEffect(() => {
        contacts && setcontactsSource([info.staff_id_one_data])
        contacts && getAllAuth()
        contacts && getAllStore()
        // eslint-disable-next-line react-hooks/exhaustive-deps
    }, [contacts])

    useEffect(() => {
        staffGet()
        // eslint-disable-next-line react-hooks/exhaustive-deps
    }, [staffPager])

    useEffect(() => {
        changelist()
    },[show])

    return (
        <React.Fragment>
            <Header navCur={4} />
            <div className="Client page u-p-20">
                <Collapse bordered={false} defaultActiveKey={['1']}>
                    <Panel header={
                        <div className="part-title">客源列表</div>
                    } key="1">
                        <div className="u-flex u-flex-wrap">
                            <div className="u-flex">
                                <div className="u-m-l-20 u-text-nowrap">城区</div>
                                <City value={[param.city, param.region, param.areas]} onChange={paramsCity} className="u-m-l-5" />
                            </div>
                            <div className="u-flex">
                                <div className="u-m-l-10 u-text-nowrap">日期</div>
                                {param.entrust && <RangePicker value={[param.entrust[0] ? moment(param.entrust[0]) : undefined, param.entrust[1] ? moment(param.entrust[1]) : undefined]} onChange={(e, es) => paramChange(setParam, param, 'entrust', es)} inputReadOnly placeholder={['委托日期', '委托日期']} className="u-m-l-5" style={{ width: 220 }} />}
                                {!param.entrust && <RangePicker value={[undefined, undefined]} onChange={(e, es) => paramChange(setParam, param, 'entrust', es)} inputReadOnly placeholder={['委托日期', '委托日期']} className="u-m-l-5" style={{ width: 220 }} />}
                            </div>
                            <div className="u-flex">
                                <div className="u-m-l-10 u-text-nowrap">智能</div>
                                <Input placeholder="查编号" value={param.number} onChange={e => paramChange(setParam, param, 'number', e.target.value)} className="u-m-l-5" style={{ width: 120 }} />
                                <Input placeholder="位置" value={param.address} onChange={e => paramChange(setParam, param, 'address', e.target.value)} style={{ width: 100 }} />
                                <Input placeholder="客户名" value={param.name} onChange={e => paramChange(setParam, param, 'name', e.target.value)} style={{ width: 100 }} />
                                {/* <Input placeholder="备注" value={param.room_num} onChange={e => paramChange(setParam, param, 'room_num', e.target.value)} style={{width: 100}} /> */}
                            </div>
                            <div className="u-flex">
                                <div className="u-m-l-10 u-text-nowrap">客户</div>
                                <Input value={param.name} onChange={e => paramChange(setParam, param, 'name', e.target.value)} placeholder="客户" className="u-m-l-5" style={{ width: 100 }} />
                            </div>
                            <div className="u-flex">
                                <div className="u-m-l-20 u-text-nowrap">面积</div>
                                <Input placeholder="0" value={param.area ? param.area[0] : ''} onChange={e => paramChange(setParam, param, 'area', e.target.value, 0)} className="u-m-l-5" style={{ width: 70 }} />
                                -
                                <Input placeholder="不限" value={param.area ? param.area[1] : ''} onChange={e => paramChange(setParam, param, 'area', e.target.value, 1)} style={{ width: 70 }} />
                            </div>
                            <div className="u-flex u-m-t-10">
                                <div className="u-m-l-20 u-text-nowrap">手机</div>
                                <Input value={param.mobile} onChange={e => paramChange(setParam, param, 'mobile', e.target.value)} placeholder="手机" className="u-m-l-5" style={{ width: 120 }} />
                            </div>
                            <div className="u-flex u-m-t-10">
                                <div className="u-m-l-10 u-text-nowrap">交易</div>
                                <Select value={param.transaction} onChange={e => paramChange(setParam, param, 'transaction', e)} allowClear placeholder="(全部)" className="u-m-l-5" style={{ width: 80 }}>
                                    <Option value="求购">求购</Option>
                                    <Option value="求租">求租</Option>
                                    <Option value="租购">租购</Option>
                                    <Option value="仅购">仅购</Option>
                                    <Option value="仅租">仅租</Option>
                                </Select>
                            </div>
                            <div className="u-flex u-m-t-10">
                                <span className="u-m-l-10 u-text-nowrap">价格</span>
                                <Input placeholder="0.00" value={param.price ? param.price[0] : ''} onChange={e => paramChange(setParam, param, 'price', e.target.value, 0)} className="u-m-l-5" style={{ width: 60 }} />
                                -
                                <Input placeholder="不限" value={param.price ? param.price[1] : ''} onChange={e => paramChange(setParam, param, 'price', e.target.value, 1)} style={{ width: 60 }} />
                            </div>
                            <div className="u-flex u-m-t-10">
                                <span className="u-m-l-10 u-text-nowrap">房型</span>
                                <Input value={param.num_room} onChange={e => paramChange(setParam, param, 'num_room', e.target.value)} placeholder="请输入房型" className="u-m-l-5" style={{ width: 100 }} />
                                {/* <span className="u-m-l-20 u-text-nowrap">房</span>
                        <Input value={param.num_office} onChange={e => paramChange(setParam, param, 'num_office', e.target.value)} className="u-m-l-10" style={{width: 50}} />
                        <span className="u-m-l-20 u-text-nowrap">厅</span>
                         <Input value={param.num_toilet} onChange={e => paramChange(setParam, param, 'num_toilet', e.target.value)} className="u-m-l-10" style={{width: 50}} />
                        <span className="u-m-l-20 u-text-nowrap">卫</span>
                        <Input value={param.num_balcony} onChange={e => paramChange(setParam, param, 'num_balcony', e.target.value)} className="u-m-l-10" style={{width: 50}} />
                        <span className="u-m-l-20 u-text-nowrap">阳台</span> */}

                            </div>
                            <div className="u-flex u-m-t-10">
                                <div className="u-m-l-10 u-text-nowrap">朝向</div>
                                <Select placeholder="(全部)" allowClear value={param.orientation} onChange={e => paramChange(setParam, param, 'orientation', e)} style={{ width: 80 }}>
                                    <Option value="未知">未知</Option>
                                    <Option value="东">东</Option>
                                    <Option value="南">南</Option>
                                    <Option value="西">西</Option>
                                    <Option value="北">北</Option>
                                    <Option value="南北">南北</Option>
                                    <Option value="东南">东南</Option>
                                    <Option value="西南">西南</Option>
                                    <Option value="东北">东北</Option>
                                    <Option value="西北">西北</Option>
                                    <Option value="东西">东西</Option>
                                </Select>
                            </div>
                            <div className="u-flex u-m-t-10">
                                <div className="u-m-l-10 u-text-nowrap">状态</div>
                                <Select value={param.state} onChange={e => paramChange(setParam, param, 'state', e)} allowClear placeholder="(全部)" className="u-m-l-5" style={{ width: 100 }}>
                                    <Option value="有效">有效</Option>
                                    <Option value="有效预定">有效预定</Option>
                                    <Option value="有效暂缓">有效暂缓</Option>
                                    <Option value="非有效">非有效</Option>
                                    <Option value="特定">预定</Option>
                                    <Option value="已售">已售</Option>
                                    <Option value="已租">已租</Option>
                                    <Option value="我售">我售</Option>
                                    <Option value="我租">我租</Option>
                                    <Option value="暂缓">暂缓</Option>
                                    <Option value="未知">未知</Option>
                                    <Option value="无效">无效</Option>
                                </Select>
                            </div>
                            <div className="u-flex u-m-t-10">
                                <div className="u-m-l-10 u-text-nowrap">类别</div>
                                <Select value={param.category} onChange={e => paramChange(setParam, param, 'category', e)} allowClear className="u-m-l-5" style={{ width: 100 }}>
                                    <Option value="老板">老板</Option>
                                    <Option value="高管">高管</Option>
                                    <Option value="白领">白领</Option>
                                    <Option value="打工">打工</Option>
                                    <Option value="个体户">个体户</Option>
                                    <Option value="公务员">公务员</Option>
                                    <Option value="工程师">工程师</Option>
                                    <Option value="自由职业">自由职业</Option>
                                    <Option value="教师">教师</Option>
                                    <Option value="医生">医生</Option>
                                    <Option value="律师">律师</Option>
                                    <Option value="农民">农民</Option>
                                    <Option value="无业">无业</Option>
                                    <Option value="其他">其他</Option>
                                </Select>
                            </div>
                            <div className="u-flex u-m-t-5">
                                <div className="u-m-l-20 u-text-nowrap">用途</div>
                                <Select value={param.purpose} onChange={e => paramChange(setParam, param, 'purpose', e)} allowClear placeholder="(全部)" className="u-m-l-5" style={{ width: 90 }}>
                                    <Option value="住宅">住宅</Option>
                                    <Option value="商住">商住</Option>
                                    <Option value="商铺">商铺</Option>
                                    <Option value="网点">网点</Option>
                                    <Option value="写字楼">写字楼</Option>
                                    <Option value="厂房">厂房</Option>
                                    <Option value="写厂">写厂</Option>
                                    <Option value="铺厂">铺厂</Option>
                                    <Option value="仓库">仓库</Option>
                                    <Option value="地皮">地皮</Option>
                                    <Option value="车位">车位</Option>
                                    <Option value="其他">其他</Option>
                                </Select>
                            </div>
                            <div className="u-flex u-m-t-5">
                                <div className="u-m-l-10 u-text-nowrap">类型</div>
                                <Select value={param.type} onChange={e => paramChange(setParam, param, 'type', e)} allowClear placeholder="(全部)" className="u-m-l-5" style={{ width: 100 }}>
                                    <Option value="多层">多层</Option>
                                    <Option value="高层">高层</Option>
                                    <Option value="小高层">小高层</Option>
                                    <Option value="多层复式">多层复式</Option>
                                    <Option value="高层复式">高层复式</Option>
                                    <Option value="多层跃式">多层跃式</Option>
                                    <Option value="高层跃式">高层跃式</Option>
                                    <Option value="独立别墅">独立别墅</Option>
                                    <Option value="联体别墅">联体别墅</Option>
                                    <Option value="双拼别墅">双拼别墅</Option>
                                    <Option value="叠加别墅">叠加别墅</Option>
                                    <Option value="围院别墅">围院别墅</Option>
                                    <Option value="裙楼">裙楼</Option>
                                    <Option value="四合院">四合院</Option>
                                </Select>
                            </div>
                            <div className="u-flex u-m-t-5">
                                <div className="u-m-l-10 u-text-nowrap">员工</div>
                                <Store value={[param.store_id, param.staff_id]} onChange={(store_id, staff_id) => paramsStaff(store_id, staff_id)} className="u-m-l-5" />
                            </div>
                            <div className="u-flex u-m-t-5 u-m-l-80">
                                <Button size="mini" type="primary" onClick={paramsSearch}>
                                    <img src={require('../assets/icon/icon-6.png').default} alt="" />
                                    <span className="u-m-l-5 u-text-nowrap">搜索</span>
                                </Button>
                                <div className="u-btn u-flex u-m-l-20" onClick={paramsReset}>
                                    <img src={require('../assets/icon/icon-7.png').default} alt="" />
                                    <span className="u-m-l-5 u-text-nowrap">清空</span>
                                </div>
                            </div>
                        </div>
                    </Panel>
                </Collapse>
                <div className="u-flex u-m-t-20">
                    <Column list={columnDefault} onSave={e => (customer?.gjck?.value ?? '') === '无' ? setjurisdiction(!0) : setColumn(e)} className="u-m-l-20" />
                    <div className="u-flex u-m-l-20 u-btn" onClick={() => setFollowShow(!0)}>
                        <img className="icon" src={require('../assets/icon/icon-31.png').default} alt="" />
                        <div>客源跟进</div>
                    </div>
                    <div className="u-flex u-m-l-20 u-btn" onClick={() => setshow(!show)}>
                        <div>展开</div>
                    </div>
                    <Button onClick={() => toggleCollect(param.guest_collect)} size="small" className="collect-btn u-m-l-20">
                        <HeartTwoTone twoToneColor={param.guest_collect ? '#eb2f96' : '#999'} />
                        <span style={{ color: param.guest_collect ? '#eb2f96' : '' }}>我的收藏</span>
                    </Button>
                    <Recycle url='client' change={setchange} func={clientGet} columns={backColumns} className="u-m-l-20" />
                </div>
                <Dropdown overlay={menu} trigger={['contextMenu']} visible={isDropdown} onVisibleChange={VisibleChange}>
                    <div className="u-m-t-20">

                        <Table rowSelection={{
                            selectedRowKeys: select,
                            onChange(e) {
                                setSelect(e)
                            }
                        }} onRow={e => ({
                            onDoubleClick: () => {
                                setisDropdown(!1)
                                clientEdit(e.id)
                            },
                            onClick: () => {
                                console.log(e);
                                setisDropdown(!1)
                                setinfo(e)
                            },
                            onContextMenu: (event) => {
                                setisDropdown(true)
                                console.log(e);
                                setinfo(e)
                                event.preventDefault()
                            },
                        })} rowKey={e => e.id} components={{
                            header: {
                                cell: ResizeableTitle
                            }
                        }} scroll={{ x: !show ? 2000 : 3000 }} size="small" bordered dataSource={source} columns={column.map((col, index) => {
                            return {
                                ...col,
                                onHeaderCell: (column) => ({
                                    width: column.width,
                                    onResize: (e, { size }) => {
                                        setColumn((column) => {
                                            const nextColumns = [...column];
                                            nextColumns[index] = {
                                                ...nextColumns[index],
                                                width: size.width
                                            }
                                            return nextColumns;
                                        })
                                    }
                                })
                            }
                        })} pagination={false} />
                    </div>

                </Dropdown>
                <div className="u-flex u-row-between u-m-t-20">
                    <div>
                        <Button type="primary" size="small" onClick={() => (customer?.kyxz?.value ?? '') === '无' ? setjurisdiction(!0) : setClient({ show: !0 })}>
                            <div className="u-flex">
                                <img src={require('../assets/icon/icon-18.png').default} alt="" />
                                <span className="u-m-l-5">新增</span>
                            </div>
                        </Button>
                        <Popconfirm title="确定删除？" okText="确定" cancelText="取消" onConfirm={clientDel}>
                            <Button className="u-m-l-20" type="primary" size="small" danger>
                                <div className="u-flex">
                                    <img src={require('../assets/icon/icon-19.png').default} alt="" />
                                    <span className="u-m-l-5">删除</span>
                                </div>
                            </Button>
                        </Popconfirm>
                    </div>
                    <Pagination showQuickJumper current={pager.page} pageSize={pager.pageSize} total={total} />
                </div>
            </div>
            <Footer isshow={'client'} info={info} genj={setFollow} />
            <Modal title="客户资料" visible={client.show} width={890} onOk={clientConfirm} onCancel={() => setClient({ show: !1 })}>
                <div className="Modal Client">
                    {mask.show && <div className="mask">
                        <Spin size="large" tip={mask.text} />
                    </div>}
                    <div className="u-flex">
                        <div className="label u-m-l-14">客户</div>
                        <Input value={clientForm.name} onChange={e => paramChange(setClientForm, clientForm, 'name', e.target.value)} className="u-m-l-10" style={{ width: 150 }} />
                        <div className="label u-m-l-20">手机</div>
                        <Input value={clientForm.mobile} onChange={e => paramChange(setClientForm, clientForm, 'mobile', e.target.value)} className="u-m-l-10" style={{ width: 150 }} />
                        <div className="label u-m-l-20">等级</div>
                        <Select value={clientForm.level} onChange={e => paramChange(setClientForm, clientForm, 'level', e)} allowClear className="u-m-l-10" style={{ width: 150 }}>
                            <Option value="A">A</Option>
                            <Option value="B">B</Option>
                            <Option value="C">C</Option>
                        </Select>
                        <div className="label u-m-l-20">现住</div>
                        <Input value={clientForm.now_address} onChange={e => paramChange(setClientForm, clientForm, 'now_address', e.target.value)} className="u-m-l-10" style={{ width: 150 }} />
                    </div>
                    <div className="u-flex u-m-t-10">
                        <div>
                            <div className="u-flex">
                                <div className="label">联系人</div>
                                <Input value={clientForm.link_man} onChange={e => paramChange(setClientForm, clientForm, 'link_man', e.target.value)} className="u-m-l-10" style={{ width: 150 }} />
                            </div>
                            <div className="u-flex u-m-t-10">
                                <div className="label">身份证</div>
                                <Input value={clientForm.id_card} onChange={e => paramChange(setClientForm, clientForm, 'id_card', e.target.value)} className="u-m-l-10" style={{ width: 150 }} />
                            </div>
                        </div>
                        <div className="u-flex u-m-l-20">
                            <div className="label">联系</div>
                            <TextArea value={clientForm.link_con} onChange={e => paramChange(setClientForm, clientForm, 'link_con', e.target.value)} className="u-m-l-10" style={{ width: 150, height: 73 }} />
                        </div>
                        <div className="u-m-l-20">
                            <div className="u-flex">
                                <div className="label">类别</div>
                                <Select value={clientForm.category} onChange={e => paramChange(setClientForm, clientForm, 'category', e)} allowClear className="u-m-l-10" style={{ width: 150 }}>
                                    <Option value="老板">老板</Option>
                                    <Option value="高管">高管</Option>
                                    <Option value="白领">白领</Option>
                                    <Option value="打工">打工</Option>
                                    <Option value="个体户">个体户</Option>
                                    <Option value="公务员">公务员</Option>
                                    <Option value="工程师">工程师</Option>
                                    <Option value="自由职业">自由职业</Option>
                                    <Option value="教师">教师</Option>
                                    <Option value="医生">医生</Option>
                                    <Option value="律师">律师</Option>
                                    <Option value="农民">农民</Option>
                                    <Option value="无业">无业</Option>
                                    <Option value="其他">其他</Option>
                                </Select>
                            </div>
                            <div className="u-flex u-m-t-10">
                                <div className="label">国籍</div>
                                <Input value={clientForm.nationality} onChange={e => paramChange(setClientForm, clientForm, 'nationality', e.target.value)} className="u-m-l-10" style={{ width: 150 }} />
                            </div>
                        </div>
                        <div className="u-m-l-20">
                            <div className="u-flex">
                                <div className="label">目的</div>
                                <Select value={clientForm.objective} onChange={e => paramChange(setClientForm, clientForm, 'objective', e)} allowClear className="u-m-l-10" style={{ width: 150 }}>
                                    <Option value="急迫">急迫</Option>
                                    <Option value="随意">随意</Option>
                                    <Option value="刚需">刚需</Option>
                                    <Option value="改善">改善</Option>
                                    <Option value="投资">投资</Option>
                                    <Option value="教育">教育</Option>
                                    <Option value="婚房">婚房</Option>
                                    <Option value="连环单">连环单</Option>
                                    <Option value="不限">不限</Option>
                                </Select>
                            </div>
                            <div className="u-flex u-m-t-10">
                                <div className="label">期限</div>
                                <Select value={clientForm.term} onChange={e => paramChange(setClientForm, clientForm, 'term', e)} allowClear className="u-m-l-10" style={{ width: 150 }}>
                                    <Option value="2天内">2天内</Option>
                                    <Option value="3天内">3天内</Option>
                                    <Option value="5天内">5天内</Option>
                                    <Option value="1周内">1周内</Option>
                                    <Option value="2周内">2周内</Option>
                                    <Option value="3周内">3周内</Option>
                                    <Option value="1月内">1月内</Option>
                                    <Option value="2月内">2月内</Option>
                                    <Option value="3月内">3月内</Option>
                                </Select>
                            </div>
                        </div>
                    </div>
                    <div className="u-flex u-m-t-10">
                        <div className="label u-m-l-14">交易</div>
                        <Select value={clientForm?.transaction ? clientForm.transaction[0] : undefined} onChange={e => paramChange(setClientForm, clientForm, 'transaction', e, 0)} allowClear className="u-m-l-10" style={{ width: 120 }}>
                            <Option value="二手房">二手房</Option>
                            <Option value="新房">新房</Option>
                            <Option value="二手房+新房">二手房+新房</Option>
                        </Select>
                        <Select value={clientForm?.transaction ? clientForm.transaction[1] : undefined} onChange={e => paramChange(setClientForm, clientForm, 'transaction', e, 1)} allowClear className="u-m-l-10" style={{ width: 120 }}>
                            <Option value="求购">求购</Option>
                            <Option value="求租">求租</Option>
                            <Option value="租购">租购</Option>
                        </Select>
                        <div className="label u-m-l-20">状态</div>
                        <Select value={clientForm.state} onChange={e => paramChange(setClientForm, clientForm, 'state', e)} className="u-m-l-10" style={{ width: 100 }}>
                            <Option value="有效">有效</Option>
                            <Option value="特定">特定</Option>
                            <Option value="已购">已购</Option>
                            <Option value="已租">已租</Option>
                            <Option value="我购">我购</Option>
                            <Option value="我租">我租</Option>
                            <Option value="暂缓">暂缓</Option>
                            <Option value="未知">未知</Option>
                            <Option value="无效">无效</Option>
                        </Select>
                        {(customer?.sksz?.value ?? '') === '无' ? '' : <Checkbox checked={clientForm.is_private === 1} onChange={e => paramChange(setClientForm, clientForm, 'is_private', e.target.checked ? 1 : 0)} className="u-m-l-10">私客</Checkbox>}
                        <Checkbox checked={clientForm.is_excellent === 1} onChange={e => paramChange(setClientForm, clientForm, 'is_excellent', e.target.checked ? 1 : 0)} className="u-m-l-10">优质客</Checkbox>
                    </div>
                    <div className="u-flex u-col-top">
                        <div>
                            <div className="u-flex u-m-t-10">
                                <div className="label u-m-l-14">地址</div>
                                <City value={[clientForm.city, clientForm.region, clientForm.areas]} onChange={clientCity} className="u-m-l-10" />
                            </div>
                            <div className="u-flex u-m-t-10">
                                <Input value={clientForm.address} onChange={e => paramChange(setClientForm, clientForm, 'address', e.target.value)} className="u-m-l-52" style={{ width: 320 }} />
                            </div>
                            <div className="u-flex u-m-t-10">
                                <div className="label u-m-l-14">房型</div>
                                <Input value={clientForm.num_room} onChange={e => paramChange(setClientForm, clientForm, 'num_room', e.target.value)} className="u-m-l-10" style={{ width: 50 }} />
                                <div className="label u-m-l-10">房</div>
                                <Input value={clientForm.num_office} onChange={e => paramChange(setClientForm, clientForm, 'num_office', e.target.value)} className="u-m-l-10" style={{ width: 50 }} />
                                <div className="label u-m-l-10">厅</div>
                                <Input value={clientForm.num_toilet} onChange={e => paramChange(setClientForm, clientForm, 'num_toilet', e.target.value)} className="u-m-l-10" style={{ width: 50 }} />
                                <div className="label u-m-l-10">卫</div>
                                <Input value={clientForm.num_balcony} onChange={e => paramChange(setClientForm, clientForm, 'num_balcony', e.target.value)} className="u-m-l-10" style={{ width: 50 }} />
                                <div className="label u-m-l-10">阳台</div>
                            </div>
                            <div className="u-flex u-m-t-10">
                                <div className="label u-m-l-14">面积</div>
                                <Input value={clientForm?.area ? clientForm.area[0] : ''} onChange={e => paramChange(setClientForm, clientForm, 'area', e.target.value, 0)} placeholder="0" className="u-m-l-10" style={{ width: 70 }} />
                                -
                                <Input value={clientForm?.area ? clientForm.area[1] : ''} onChange={e => paramChange(setClientForm, clientForm, 'area', e.target.value, 1)} placeholder="0" style={{ width: 70 }} />
                                <div className="label u-m-l-10">委托</div>
                                <DatePicker value={clientForm?.entrust ? moment(clientForm.entrust) : undefined} onChange={(e, es) => paramChange(setClientForm, clientForm, 'entrust', es)} placeholder="委托日期" className="u-m-l-10" style={{ width: 145 }} />
                            </div>
                            <div className="u-flex u-m-t-10">
                                <div className="label u-m-l-14">价格</div>
                                <Input value={clientForm?.price ? clientForm.price[0] : ''} onChange={e => paramChange(setClientForm, clientForm, 'price', e.target.value, 0)} placeholder="0" className="u-m-l-10" style={{ width: 70 }} />
                                -
                                <Input value={clientForm?.price ? clientForm.price[1] : ''} onChange={e => paramChange(setClientForm, clientForm, 'price', e.target.value, 1)} placeholder="0" style={{ width: 70 }} />
                                {(customer?.source?.value ?? 1) ?
                                    <>
                                        <div className="label u-m-l-10">来源</div>
                                        <Select value={clientForm?.source ? clientForm.source[0] : ''} onChange={e => paramChange(setClientForm, clientForm, 'source', e, 0)} allowClear className="u-m-l-10" style={{ width: 70 }}>
                                            <Option value="来电">来电</Option>
                                            <Option value="来访">来访</Option>
                                            <Option value="中介">中介</Option>
                                            <Option value="朋友">朋友</Option>
                                            <Option value="广告">广告</Option>
                                            <Option value="扫街">扫街</Option>
                                            <Option value="网络">网络</Option>
                                            <Option value="搜房">搜房</Option>
                                            <Option value="口碑">口碑</Option>
                                        </Select>
                                        -
                                        <Select value={clientForm?.source ? clientForm.source[1] : ''} onChange={e => paramChange(setClientForm, clientForm, 'source', e, 1)} allowClear style={{ width: 70 }}>
                                            <Option value="A-独家">A-独家</Option>
                                            <Option value="B-签约">B-签约</Option>
                                            <Option value="C-未签">C-未签</Option>
                                        </Select>
                                    </>
                                    : ''}
                            </div>
                            <div className="u-flex u-m-t-10">
                                <div className="label u-m-l-14">首付</div>
                                <Input value={clientForm?.one_payments ? clientForm.one_payments[0] : ''} onChange={e => paramChange(setClientForm, clientForm, 'one_payments', e.target.value, 0)} placeholder="0" className="u-m-l-10" style={{ width: 70 }} />
                                -
                                <Input value={clientForm?.one_payments ? clientForm.one_payments[1] : ''} onChange={e => paramChange(setClientForm, clientForm, 'one_payments', e.target.value, 1)} placeholder="0" style={{ width: 70 }} />
                                <div className="label u-m-l-10">月供</div>
                                <Input value={clientForm?.mon_supply ? clientForm.mon_supply[0] : ''} onChange={e => paramChange(setClientForm, clientForm, 'mon_supply', e.target.value, 0)} placeholder="0" className="u-m-l-10" style={{ width: 70 }} />
                                -
                                <Input value={clientForm?.mon_supply ? clientForm.mon_supply[1] : ''} onChange={e => paramChange(setClientForm, clientForm, 'mon_supply', e.target.value, 1)} placeholder="0" style={{ width: 70 }} />
                            </div>
                            <div className="u-flex u-m-t-10">
                                <div className="label">社保/个税</div>
                                <Input value={clientForm.social_security} onChange={e => paramChange(setClientForm, clientForm, 'social_security', e.target.value)} className="u-m-l-10" style={{ width: 320 }} />
                            </div>
                            <div className="u-flex u-m-t-10">
                                <div className="label">现有贷款</div>
                                <Input value={clientForm.loan} onChange={e => paramChange(setClientForm, clientForm, 'loan', e.target.value)} className="u-m-l-10" style={{ width: 120 }} />
                                <div className="label u-m-l-20">现有住房</div>
                                <Input value={clientForm.housing} onChange={e => paramChange(setClientForm, clientForm, 'housing', e.target.value)} className="u-m-l-10" style={{ width: 120 }} />
                            </div>
                        </div>
                        <div className="u-m-l-20">
                            <div className="u-flex u-m-t-10">
                                <div className="label u-m-l-20">用途</div>
                                <Select value={clientForm.purpose} onChange={e => paramChange(setClientForm, clientForm, 'purpose', e)} allowClear className="u-m-l-10" style={{ width: 150 }}>
                                    <Option value="住宅">住宅</Option>
                                    <Option value="商住">商住</Option>
                                    <Option value="商铺">商铺</Option>
                                    <Option value="网点">网点</Option>
                                    <Option value="写字楼">写字楼</Option>
                                    <Option value="厂房">厂房</Option>
                                    <Option value="写厂">写厂</Option>
                                    <Option value="铺厂">铺厂</Option>
                                    <Option value="仓库">仓库</Option>
                                    <Option value="地皮">地皮</Option>
                                    <Option value="车位">车位</Option>
                                    <Option value="其他">其他</Option>
                                </Select>
                                <div className="label u-m-l-20">楼层</div>
                                <Select value={clientForm.floor} onChange={e => paramChange(setClientForm, clientForm, 'floor', e)} allowClear className="u-m-l-10" style={{ width: 150 }}>
                                    <Option value="低楼层">低楼层</Option>
                                    <Option value="中楼层">中楼层</Option>
                                    <Option value="高楼层">高楼层</Option>
                                    <Option value="不要顶楼">不要顶楼</Option>
                                    <Option value="不限">不限</Option>
                                </Select>
                            </div>
                            <div className="u-flex u-m-t-10">
                                <div className="label u-m-l-20">类型</div>
                                <Select value={clientForm.type} onChange={e => paramChange(setClientForm, clientForm, 'type', e)} allowClear className="u-m-l-10" style={{ width: 150 }}>
                                    <Option value="多层">多层</Option>
                                    <Option value="高层">高层</Option>
                                    <Option value="小高层">小高层</Option>
                                    <Option value="多层复式">多层复式</Option>
                                    <Option value="高层复式">高层复式</Option>
                                    <Option value="高层跃式">高层跃式</Option>
                                    <Option value="独立别墅">独立别墅</Option>
                                    <Option value="联体别墅">联体别墅</Option>
                                    <Option value="双拼别墅">双拼别墅</Option>
                                    <Option value="叠加别墅">叠加别墅</Option>
                                    <Option value="围院别墅">围院别墅</Option>
                                    <Option value="裙楼">裙楼</Option>
                                    <Option value="四合院">四合院</Option>
                                </Select>
                                <div className="label u-m-l-20">朝向</div>
                                <Select value={clientForm.orientation} onChange={e => paramChange(setClientForm, clientForm, 'orientation', e)} allowClear className="u-m-l-10" style={{ width: 150 }}>
                                    <Option value="未知">未知</Option>
                                    <Option value="东">东</Option>
                                    <Option value="南">南</Option>
                                    <Option value="西">西</Option>
                                    <Option value="北">北</Option>
                                    <Option value="南北">南北</Option>
                                    <Option value="东南">东南</Option>
                                    <Option value="西南">西南</Option>
                                    <Option value="东北">东北</Option>
                                    <Option value="西北">西北</Option>
                                    <Option value="东西">东西</Option>
                                </Select>
                            </div>
                            <div className="u-flex u-m-t-10">
                                <div className="label u-m-l-20">装修</div>
                                <Select value={clientForm.renovation} onChange={e => paramChange(setClientForm, clientForm, 'renovation', e)} allowClear className="u-m-l-10" style={{ width: 150 }}>
                                    <Option value="毛胚">毛胚</Option>
                                    <Option value="清水">清水</Option>
                                    <Option value="简装">简装</Option>
                                    <Option value="中装">中装</Option>
                                    <Option value="精装">精装</Option>
                                    <Option value="豪装">豪装</Option>
                                </Select>
                                <div className="label u-m-l-20">楼龄</div>
                                <Select value={clientForm.building_age} onChange={e => paramChange(setClientForm, clientForm, 'building_age', e)} allowClear className="u-m-l-10" style={{ width: 150 }}>
                                    <Option value="不限">不限</Option>
                                    <Option value="5年以内">5年以内</Option>
                                    <Option value="5-10年">5-10年</Option>
                                    <Option value="10-20年">10-20年</Option>
                                    <Option value="20-30年">20-30年</Option>
                                </Select>
                            </div>
                            <div className="u-flex u-m-t-10">
                                <div className="label u-m-l-20">配套</div>
                                <Select value={clientForm.matching} onChange={e => paramChange(setClientForm, clientForm, 'matching', e)} allowClear mode="multiple" className="u-m-l-10" style={{ width: 150 }}>
                                    <Option value="地砖">地砖</Option>
                                    <Option value="木地板">木地板</Option>
                                    <Option value="地毯">地毯</Option>
                                    <Option value="地胶">地胶</Option>
                                    <Option value="水泥地">水泥地</Option>
                                </Select>
                                <div className="label u-m-l-20">付款</div>
                                <Select value={clientForm.payment} onChange={e => paramChange(setClientForm, clientForm, 'payment', e)} allowClear className="u-m-l-10" style={{ width: 150 }}>
                                    <Option value="一次付清">一次付清</Option>
                                    <Option value="按揭方式">按揭方式</Option>
                                    <Option value="垫资解按">垫资解按</Option>
                                    <Option value="年租">年租</Option>
                                    <Option value="半年租">半年租</Option>
                                    <Option value="季租">季租</Option>
                                    <Option value="月租">月租</Option>
                                </Select>
                            </div>
                            <div className="u-flex u-m-t-10">
                                <div className="label u-m-l-20">优惠</div>
                                <Select value={clientForm.discount} onChange={e => paramChange(setClientForm, clientForm, 'discount', e)} allowClear mode="multiple" className="u-m-l-10" style={{ width: 150 }}>
                                    <Option value="报机票">报机票</Option>
                                    <Option value="报车费">报车费</Option>
                                    <Option value="包住宿">包住宿</Option>
                                </Select>
                                <div className="label u-m-l-20">付佣</div>
                                <Select value={clientForm.commission} onChange={e => paramChange(setClientForm, clientForm, 'commission', e)} allowClear className="u-m-l-10" style={{ width: 150 }}>
                                    <Option value="商议">商议</Option>
                                    <Option value="给全佣">给全佣</Option>
                                    <Option value="九折佣">九折佣</Option>
                                    <Option value="八折佣">八折佣</Option>
                                    <Option value="七折佣">七折佣</Option>
                                    <Option value="五折佣">五折佣</Option>
                                    <Option value="不给佣">不给佣</Option>
                                </Select>
                            </div>
                            <div className="u-flex u-m-t-10">
                                <div className="label u-m-l-20">员工</div>
                                <Store value={[clientForm.store_id_1, clientForm.staff_id_1]} onChange={(store_id, staff_id) => clientStaff(1, store_id, staff_id)} className="u-m-l-10" />
                            </div>
                            <div className="u-flex u-m-t-10">
                                <div className="label u-m-l-20">员工</div>
                                <Store value={[clientForm.store_id_2, clientForm.staff_id_2]} onChange={(store_id, staff_id) => clientStaff(2, store_id, staff_id)} className="u-m-l-10" />
                            </div>
                        </div>
                    </div>
                    <div className="u-flex u-m-t-10">
                        <div className="label u-m-l-14">备注</div>
                        <TextArea className="u-m-l-10" value={clientForm.memo} onChange={e => paramChange(setClientForm, clientForm, 'memo', e.target.value)} style={{ width: 780, height: 80 }} />
                    </div>
                </div>
            </Modal>
            <Modal title={`${beltType[1]}看单`} visible={beltLog.show} zIndex={999} width={600} footer={false} onCancel={() => setBeltLog({ show: !1 })}>
                <div className="Modal">
                    <Table rowKey={e => e.id} rowSelection={{
                        selectedRowKeys: beltLogSelect,
                        onChange(e) {
                            setBeltLogSelect(e)
                        }
                    }} bordered size="small" dataSource={beltLogSource} columns={beltLogColumn} pagination={false} />
                    <div className="u-m-t-10 u-flex u-row-between">
                        <div>
                            <Button type="primary" size="small" onClick={() => setBelt({ show: !0 })}>
                                <div className="u-flex">
                                    <img src={require('../assets/icon/icon-18.png').default} alt="" />
                                    <span className="u-m-l-5">新增</span>
                                </div>
                            </Button>
                            <Popconfirm title="确定删除？" okText="确定" cancelText="取消" onConfirm={() => beltDel('')}>
                                <Button className="u-m-l-20" type="primary" size="small" danger>
                                    <div className="u-flex">
                                        <img src={require('../assets/icon/icon-19.png').default} alt="" />
                                        <span className="u-m-l-5">删除</span>
                                    </div>
                                </Button>
                            </Popconfirm>
                        </div>
                        <Pagination showQuickJumper current={beltLogPager.page} pageSize={beltLogPager.pageSize} total={beltLogTotal} onChange={(page, pageSize) => setBeltLogPager({ page, pageSize })} />
                    </div>
                </div>
            </Modal>
            <Modal title={`${beltType[1]}看单`} visible={belt.show} maskClosable={!1} width={600} onOk={beltConfirm} onCancel={() => setBelt({ show: !1 })}>
                <div className="Modal">
                    <div className='u-flex'>
                        <div>{`${beltType[1]}看单状态:`} </div>
                        <p className='u-m-t-14 u-m-l-5 u-m-r-5'>{moment().format("YYYY-MM-DD HH:mm:ss")}</p> 
                        <div>{`生成${beltType[1]}看单！`}</div>
                        <div className='u-m-l-10'>{`${beltType[1]}看结果：`}</div>
                        <Input disabled value={`${beltType[1]}看中`} style={{maxWidth:120}}/>
                    </div>
                    <div className="title u-m-t-5">客源信息</div>
                    <div className="u-flex u-m-t-20">
                        <div className="label">客源编号</div>
                        <Input disabled value={beltClient.number} className="u-m-l-10" style={{ maxWidth: 120 }} />
                        <div className="label u-m-l-20">姓名</div>
                        <Input disabled value={beltClient.name} className="u-m-l-10" style={{ maxWidth: 120 }} />
                        <div className="label u-m-l-20">楼层</div>
                        <Input disabled value={beltClient.floor} className="u-m-l-10" style={{ maxWidth: 120 }} />
                    </div>
                    <div className="u-flex u-m-t-20">
                        <div className="label u-m-l-28">城区</div>
                        <Input disabled className="u-m-l-10" style={{ maxWidth: 120 }} />
                        <div className="label u-m-l-20">片区</div>
                        <Input disabled className="u-m-l-10" style={{ maxWidth: 120 }} />
                        <div className="label u-m-l-20">位置</div>
                        <Input disabled className="u-m-l-10" style={{ maxWidth: 120 }} />
                    </div>
                    <div className="u-flex u-m-t-20">
                        <div className="label u-m-l-28">面积</div>
                        <Input disabled value={beltClient.area} className="u-m-l-10" style={{ width: 120 }} />
                        <div className="label u-m-l-20">价格</div>
                        <Input disabled value={beltClient.price} className="u-m-l-10" style={{ width: 120 }} />
                        <div className="label u-m-l-20">用途</div>
                        <Input disabled value={beltClient.purpose} className="u-m-l-10" style={{ width: 120 }} />
                    </div>
                    <div className="title u-m-t-10">{beltType[1]}看单信息</div>
                    <div className="u-flex u-m-t-20">
                        <div className="label u-m-l-14">{beltType[1]}看人</div>
                        <Store value={[beltForm.store_id, beltForm.staff_id]} onChange={beltStore} className="u-m-l-10" />
                        <div className="label u-m-l-20">交易类型</div>
                        <Select value={beltForm.pay_type} allowClear placeholder="(全部)" onChange={e => beltChange('pay_type', e)} className="u-m-l-10" style={{ width: 120 }}>
                            <Option value="求购">求购</Option>
                            <Option value="求租">求租</Option>
                            <Option value="租购">租购</Option>
                        </Select>
                    </div>
                    <div className="u-flex u-m-t-20">
                        <div className="label">{beltType[1]}看时间</div>
                        <DatePicker value={beltForm?.time ? moment(beltForm.time) : ''} onChange={(e, es) => beltChange('time', es)} placeholder="约看时间" className="u-m-l-10" style={{ width: 120 }} />
                        <div className="label u-m-l-20">会合地点</div>
                        <Input value={beltForm.place} onChange={e => beltChange('place', e.target.value)} placeholder="会合地点" className="u-m-l-10" style={{ width: 250 }} />
                    </div>
                    <div className="u-flex u-m-t-20">
                        <div className="label u-m-l-28">备注</div>
                        <TextArea value={beltForm.memo} onChange={e => beltChange('memo', e.target.value)} className="u-m-l-10" style={{ width: 455, height: 70 }} />
                    </div>
                    <div className="title u-m-t-10">{beltType[1]}看房源信息</div>
                    <div className="u-m-t-10">
                        <Button type="primary" ghost size="small" onClick={() => setHouse({ show: !0 })}>添加房源</Button>
                    </div>
                    <div className="u-m-t-10">
                        <Table bordered size="small" rowKey={(e) => `${e.id}-`} scroll={{ x: 600 }} dataSource={houseSource} columns={houseColumn} pagination={false} />
                    </div>
                    {beltType[0] === 'belt' && <>
                        <div className="title u-m-t-10">{beltType[1]}看反馈</div>
                        <div className="u-m-t-10">
                            <TextArea value={beltForm.feedback} onChange={e => beltChange('feedback', e.target.value)} style={{ width: '100%' }} rows={4} />
                        </div>
                    </>}
                </div>
            </Modal>
            <Modal title="添加房源" visible={house.show} width={900} zIndex={1001} onOk={houseConfirm} onCancel={houseCancel} okText="添加">
                <div className="Modal">
                    <div className="u-flex">
                        <div className="u-text-nowrap">城区</div>
                        <City value={[houseForm.city, houseForm.region, houseForm.area]} onChange={houseCityChange} className="u-m-l-10" />
                        <div className="u-m-l-20 u-text-nowrap">智能</div>
                        <Input placeholder="楼盘" value={houseForm.estate_name} onChange={e => paramChange(setHouseForm, houseForm, 'estate_name', e.target.value)} className="u-m-l-10" style={{ width: 120 }} />
                        <Input placeholder="栋座" value={houseForm.position} onChange={e => paramChange(setHouseForm, houseForm, 'position', e.target.value)} style={{ width: 100 }} />
                        <Input placeholder="房号" value={houseForm.room_num} onChange={e => paramChange(setHouseForm, houseForm, 'room_num', e.target.value)} style={{ width: 100 }} />
                        <Button size="mini" type="primary" onClick={() => paramChange(setHousePager, housePager, 'page', 1)}>
                            <img src={require('../assets/icon/icon-6.png').default} alt="" />
                        </Button>
                        <div className="u-btn u-flex u-m-l-20">
                            <img src={require('../assets/icon/icon-7.png').default} alt="" />
                            <span className="u-m-l-5 u-text-nowrap">清空</span>
                        </div>
                    </div>
                    <div className="u-flex u-m-t-20">
                        <div className="u-text-nowrap">交易</div>
                        <Select placeholder="(全部)" allowClear value={houseForm.transaction} onChange={e => paramChange(setHouseForm, houseForm, 'transaction', e)} className="u-m-l-10" style={{ width: 100 }}>
                            <Option value="出售">出售</Option>
                            <Option value="出租">出租</Option>
                            <Option value="租售">租售</Option>
                        </Select>

                        <div className="u-m-l-20 u-text-nowrap">用途</div>
                        <Select placeholder="(全部)" allowClear value={houseForm.purpose} onChange={e => paramChange(setHouseForm, houseForm, 'purpose', e)} className="u-m-l-10" style={{ width: 100 }}>
                            <Option value="住宅">住宅</Option>
                            <Option value="商住">商住</Option>
                            <Option value="商铺">商铺</Option>
                            <Option value="网点">网点</Option>
                            <Option value="写字楼">写字楼</Option>
                            <Option value="厂房">厂房</Option>
                            <Option value="写厂">写厂</Option>
                            <Option value="铺厂">铺厂</Option>
                            <Option value="仓库">仓库</Option>
                            <Option value="地皮">地皮</Option>
                            <Option value="车位">车位</Option>
                            <Option value="其他">其他</Option>
                        </Select>
                        <div className="u-m-l-20 u-text-nowrap">面积</div>
                        <Input placeholder="0.00" value={houseForm.house_area ? houseForm.house_area[0] : ''} onChange={e => paramChange(setHouseForm, houseForm, 'house_area', e.target.value, 0)} className="u-m-l-10" style={{ width: 100 }} />
                        -
                        <Input placeholder="不限" value={houseForm.house_area ? houseForm.house_area[1] : ''} onChange={e => paramChange(setHouseForm, houseForm, 'house_area', e.target.value, 1)} style={{ width: 100 }} />
                    </div>
                    <div className="u-m-t-20">
                        <Table rowKey={e => e.id} rowSelection={{
                            selectedRowKeys: houseSelect,
                            onChange(e) {
                                setHouseSelect(e)
                            }
                        }} bordered size="small" scroll={{ x: 1000 }} dataSource={houseList} columns={houseListColumn} pagination={false} />
                    </div>
                    <div className="u-m-t-10 u-text-right">
                        <Pagination showQuickJumper current={housePager.page} pageSize={housePager.pageSize} total={houseTotal} />
                    </div>
                </div>
            </Modal>
            <Modal title="添加跟进" width={370} visible={follow.show} onOk={followFormConfirm} onCancel={() => setFollow({ show: !1 })}>
                <div className="Modal">
                    {mask.show && (
                        <div className="mask">
                            <Spin size="large" tip={mask.text} />
                        </div>
                    )}
                    <div className="u-flex">
                        <div className="label">跟进员工</div>
                        <Store value={[followForm.store_id, followForm.staff_id]} onChange={followStaffChange} className="u-m-l-10" />
                    </div>
                    <div className="u-flex u-m-t-20">
                        <div className="label">方式类型</div>
                        <Select value={followForm.mode} onChange={e => followFormChange('mode', e)} placeholder="跟进方式" className="u-m-l-10" style={{ width: 120 }}>
                            <Option value="去电">去电</Option>
                            <Option value="来电">来电</Option>
                            <Option value="看房">看房</Option>
                            <Option value="勘察">勘察</Option>
                            <Option value="来访">来访</Option>
                            <Option value="拜访">拜访</Option>
                            <Option value="派单">派单</Option>
                            <Option value="短信">短信</Option>
                            <Option value="邮件">邮件</Option>
                            <Option value="信函">信函</Option>
                            <Option value="申请">申请</Option>
                            <Option value="修改">修改</Option>
                            <Option value="保留">保留</Option>
                        </Select>
                        <Select value={followForm.type} onChange={e => followFormChange('type', e)} placeholder="跟进类型" className="u-m-l-10" style={{ width: 120 }}>
                            <Option value="普通跟进">普通跟进</Option>
                            <Option value="重点跟进">重点跟进</Option>
                            <Option value="专属跟进">专属跟进</Option>
                        </Select>
                    </div>
                    <div className="u-flex u-m-t-20">
                        <div className="label">跟进内容</div>
                        <Input value={followForm.content} onChange={e => followFormChange('content', e.target.value)} placeholder="跟进内容" className="u-m-l-10" style={{ width: 250 }} />
                    </div>
                    <div className="u-flex u-m-t-20">
                        <div className="label">时间提醒</div>
                        <DatePicker value={followForm.time ? moment(followForm.time) : ''} onChange={(e, es) => followFormChange('time', es)} placeholder="跟进时间" className="u-m-l-10" style={{ width: 120 }} />
                        <DatePicker placeholder="下次提醒" value={followForm.remind ? moment(followForm.remind) : ''} onChange={(e, es) => followFormChange('remind', es)} className="u-m-l-10" style={{ width: 120 }} />
                    </div>
                    <div className="u-flex u-m-t-20">
                        <div className="label u-text-nowrap">跟进图片</div>
                        <Upload {...uploadConfig} className="u-m-l-10">
                            {fileList.length < 1 && (<div>
                                <PlusOutlined />
                                <div style={{ marginTop: 8 }}>Upload</div>
                            </div>)}
                        </Upload>
                    </div>
                    <div className="tip u-m-t-20 u-m-l-10">
                        <span className="tip-icon">*</span>
                        <span>跟进保存后不可修改，请确认内容后再保存</span>
                    </div>
                </div>
            </Modal>
            <Modal title="客源跟进" width={1280} visible={followShow} footer={false} onCancel={() => setFollowShow(!1)} destroyOnClose>
                <div className="Modal">
                    <div className="u-flex u-row-between">
                        <Recycle url='client.follow' func={followFunc.list} columns={followColumn} />
                        <div className="u-flex">
                            <Store value={[followSearch.store_id, followSearch.staff_id]} onChange={followFunc.staffChange} className="u-m-l-10" />
                            <Button size="mini" type="primary" onClick={followFunc.list} className="u-m-l-10">
                                <img src={require('../assets/icon/icon-6.png').default} alt="" />
                                <span className="u-m-l-5 u-text-nowrap">搜索</span>
                            </Button>
                        </div>
                    </div>
                    <div className="u-m-t-20">
                        <Table bordered rowKey={e => e.id} rowSelection={{
                            selectedRowKeys: followSelect,
                            onChange(e) {
                                setFollowSelect(e)
                            },

                        }} size="small" scroll={{ x: 980 }} dataSource={followSource} columns={followColumns} pagination={false} />
                    </div>
                    <div className="u-flex u-row-between u-m-t-20">
                        <Popconfirm title="确定删除？" okText="确定" cancelText="取消" onConfirm={followFunc.del}>
                            <Button type="primary" size="small" danger>
                                <div className="u-flex">
                                    <img src={require('../assets/icon/icon-19.png').default} alt="" />
                                    <span className="u-m-l-5">删除</span>
                                </div>
                            </Button>
                        </Popconfirm>
                        <Pagination showQuickJumper current={followPager.page} pageSize={followPager.pageSize} total={followTotal} onChange={(page, pageSize) => setFollowPager({ page, pageSize })} />
                    </div>
                </div>
            </Modal>
            <Modal title="跟进信息" width={1000} visible={ope.show} footer={false} onCancel={() => setOpe({ show: !1 })} destroyOnClose>
                <div className="Modal">
                    <div className="detail-title main-color">【{followData.name}】 {followData.mobile}</div>
                    <div className="u-content-color u-m-t-20">求购意向：{followData.city_data?.name ?? ''}{followData.region_data?.name ?? ''}{followData.area_data?.name ?? ''}{followData.purpose ? `,${followData.purpose}` : ''}</div>
                    <div className="u-content-color u-flex u-col-center u-l-h-2">
                        <span>员工信息：</span>
                        <span>{followData.store_id_one_data?.name ?? ''}</span>
                        <span className="u-m-l-10">{followData.staff_id_one_data?.nickname ?? ''}</span>
                        <span className="u-m-l-10">【{followData.entrust} 委托】</span>
                    </div>
                </div>
                <div className="u-m-t-20">
                    <Table bordered rowKey={e => e.id} rowSelection={{
                        selectedRowKeys: followMsgSelect,
                        onChange(e) {
                            setFollowMsgSelect(e)
                        }
                    }} size="small" dataSource={followList} columns={followMsgColumns} pagination={false} />
                </div>
                <div className="u-flex u-row-between u-m-t-20">
                    <div className="u-flex">
                        <Button type="primary" size="small" ghost onClick={() => setFollow({ show: !0 })}>写跟进</Button>
                        <Popconfirm title="确定删除？" okText="确定" cancelText="取消" onConfirm={followFunc.del2}>
                            <Button type="primary" size="small" danger className="u-flex u-m-l-20">
                                <img src={require('../assets/icon/icon-19.png').default} alt="" />
                                <span className="u-m-l-5">删除</span>
                            </Button>
                        </Popconfirm>
                    </div>
                    <Pagination showQuickJumper current={followMsgPager.page} pageSize={followMsgPager.pageSize} total={followMsgTotal} onChange={(page, pageSize) => setFollowMsgPager({ page, pageSize })} />
                </div>
            </Modal>
            <Modal visible={preview.show} width={1000} footer={null} zIndex={1010} onCancel={() => { setPreview({ show: !1 }) }}>
                <img src={preview.content} alt="" style={{ width: '100%' }} />
            </Modal>
            <Modal title="员工通讯录" width={1280} visible={contacts} footer={false} onCancel={() => setcontacts(!1)} destroyOnClose>
                <div className="Modal">
                    <div className="u-flex u-row-right">
                        <div className="u-flex">
                            <div className="u-m-l-20 u-text-nowrap">部门</div>
                            <Select value={staffSearch.store_id} onChange={e => paramcontacts('store_id', e)} placeholder="(全部)" allowClear className="u-m-l-10" style={{ width: 130 }}>
                                {allStore.map(store => (
                                    <Option key={'store-' + store.id} value={store.id}>{store.name}</Option>
                                ))}
                            </Select>
                        </div>
                        <div className="u-flex">
                            <div className="u-m-l-20 u-text-nowrap">姓名</div>
                            <Input value={staffSearch.nickname} onChange={e => paramcontacts('nickname', e.target.value)} className="u-m-l-5" style={{ width: 100 }} />
                        </div>
                        <div className="u-flex">
                            <div className="u-m-l-20 u-text-nowrap">职务</div>
                            <Select onChange={e => paramcontacts('group_id', e)} placeholder="(全部)" allowClear className="u-m-l-10" style={{ width: 130 }}>
                                {allAuth.map(group => (
                                    <Option key={'store-' + group.id} value={group.id}>{group.name}</Option>
                                ))}
                            </Select>
                        </div>
                        <div className="u-flex">
                            {/*  format="MM-DD"  */}
                            <div className="u-m-l-20 u-text-nowrap">生日</div>
                            {staffSearch.s_birthday && <RangePicker value={[staffSearch.s_birthday ? moment(staffSearch.s_birthday) : undefined, staffSearch.e_birthday ? moment(staffSearch.e_birthday) : undefined]} onChange={(e, es) => paramcontacts('birthday', es)} inputReadOnly allowClear className="u-m-l-10" style={{ width: 200 }} format="MM-DD" />}
                            {!staffSearch.s_birthday && <RangePicker value={[undefined, undefined]} onChange={(e, es) => paramcontacts('birthday', es)} inputReadOnly className="u-m-l-10" style={{ width: 200 }} format="MM-DD" />}
                        </div>
                        <Button size="mini" type="primary" onClick={staffFind} className="u-m-l-20">
                            <img src={require('../assets/icon/icon-6.png').default} alt="" />
                            <span className="u-m-l-5 u-text-nowrap">搜索</span>
                        </Button>
                    </div>
                    <div className="u-m-t-20">
                        <Table bordered rowKey={e => e.id} size="small" scroll={{ x: 980 }} dataSource={contactsSource} columns={contactsTable} pagination={false} />
                    </div>
                    <div className="u-flex u-row-between u-m-t-20">
                        <Pagination showQuickJumper current={staffPager.page} pageSize={staffPager.pageSize} total={staffTotal} />
                    </div>
                </div>
            </Modal>
            <Modal title="提示信息" visible={ismessage} onOk={() => {
                setismessage(!1)
            }} onCancel={() => {
                setismessage(!1)
            }}>
                <div className="u-flex u-col-center">
                    <img src={require('../assets/icon/icon-41.png').default} className="u-m-l-10 u-btn" style={{ width: 50 }} alt="" />
                    <p className="u-m-l-10" style={{ fontSize: 18, fontWeight: 500 }}>面积[最大值]要大于[最小值]</p>
                </div>
            </Modal>
            <Modal title="提示信息" visible={ismessage2} onOk={() => {
                setismessage2(!1)
            }} onCancel={() => {
                setismessage2(!1)
            }}>
                <div className="u-flex u-col-center">
                    <img src={require('../assets/icon/icon-41.png').default} className="u-m-l-10 u-btn" style={{ width: 50 }} alt="" />
                    <p className="u-m-l-10" style={{ fontSize: 18, fontWeight: 500 }}>价格[最大值]要大于[最小值]</p>
                </div>
            </Modal>
            <Modal title="提示" visible={jurisdiction} footer={false} onCancel={() => setjurisdiction(!1)} destroyOnClose>
                <h3>权限不足</h3>
            </Modal>
        </React.Fragment>
    );

    
    function paramsCity(city, region, area) {
        let newParam = { ...param }
        newParam.city = city
        newParam.region = region
        newParam.areas = area
        setParam(newParam)
    }
    function paramsStaff(store_id, staff_id) {
        setchange(!1)
        let newParam = { ...param }
        newParam.store_id = store_id
        newParam.sfaff_id = staff_id
        setParam(newParam)
    }
    function paramsSearch() {
        setchange(!1)
        let page = { ...pager }
        page.page = 1
        setPager(page)
    }
    function paramsReset() {
        setchange(!1)
        setParam({})
        setPager(pagerDefault)
    }
    function clientGet() {
        if ((customer?.kyck?.value ?? '') === '无') return setjurisdiction(!0)
        if (change && JSON.parse(sessionStorage.getItem('client_list'))) {
            const house = JSON.parse(sessionStorage.getItem('client_list'))
            for (const key in house.rows) {
                if (key * 1 === pager.page) {
                    setSource(house.rows[key])
                    setTotal(house.total)
                    return
                }
            }
        }
        let newParam = enSplit(param, { entrust: ' - ', area: '-', price: '-', source: '-', one_payments: '-', mon_supply: '-' })
        http('client.index', {
            ...fieldGet(field, newParam, pager.page, pager.pageSize)
        }).then(res => {
            if (res.code === 1) {
                const page = pager.page
                if (total && change) {
                    let arr = JSON.parse(sessionStorage.getItem('client_list'))
                    arr.rows[page] = []
                    res.data.rows.forEach(i => arr.rows[page].push(i))
                    sessionStorage.setItem('client_list', JSON.stringify(arr))
                    setchange(!0)
                    setSource(res.data.rows)
                    setTotal(res.data.total)
                    return
                }
                const data = {
                    total: res.data.total,
                    rows: {
                        [page]: res.data.rows
                    }
                }
                sessionStorage.setItem('client_list', JSON.stringify(data))
                setchange(!0)
                setParam({})
                setSource(res.data.rows)
                setTotal(res.data.total)
            } else {
                notification.error({
                    message: res.msg || '操作失败，请重试'
                })
            }
        }).catch(err => console.log(err))
    }
    function clientDel(id) {
        if ((customer?.kysc?.value ?? '') === '无') return setjurisdiction(!0)
        let ids = id > 0 ? [id] : select
        http('client.del', { ids }).then(res => {
            if (res.code === 1) {
                notification.success({
                    message: res.msg || '操作成功'
                })
                setchange(!1)
            } else {
                notification.error({
                    message: res.msg || '操作失败，请重试'
                })
            }
            clientGet()
            setOpe({ show: !1 })
            setFollowData({})
        })
    }
    function clientEdit(ids) {
        if ((customer?.qbxg?.value ?? '') === '无') return setjurisdiction(!0)
        http('client.one', { ids }).then(res => {
            if (res.code === 1) {
                let newForm = exSplit(res.data, { area: '-', discount: ',', matching: ',', mon_supply: '-', one_payments: '-', price: '-', source: '-', transaction: '-' })
                setClientForm(newForm)
                setClient({ show: !0 })
            }
        })
    }
    // 客源-城市
    function clientCity(city, region, area) {
        let newForm = { ...clientForm }
        newForm.city = city
        newForm.region = region
        newForm.areas = area
        setClientForm(newForm)
    }
    // 客源-员工
    function clientStaff(ind, store_id, staff_id) {
        let newParams = { ...clientForm }
        newParams['store_id_' + ind] = store_id
        newParams['staff_id_' + ind] = staff_id
        setClientForm(newParams)
    }
    // 客源-新增-提交
    function clientConfirm() {
        if (clientForm.area[0] > clientForm.area[1]) {
            setismessage(!0)
            return
        }
        if (clientForm.price[0] > clientForm.price[1]) {
            setismessage2(!0)
            return
        }
        setMask({ show: !0, text: '提交中...' })
        let newParam = enSplit(clientForm, { area: '-', discount: ',', matching: ',', mon_supply: '-', one_payments: '-', price: '-', source: '-', transaction: '-' })
        let url = clientForm?.id ? 'client.edit' : 'client.add'
        http(url, { row: newParam }).then(res => {
            if (res.code === 1) {
                notification.success({
                    message: res.msg || '操作成功'
                })
                setchange(!1)
                setClientForm({})
                setClient({ show: !1 })
                clientGet()
            } else {
                notification.error({
                    message: res.msg || '操作失败，请重试'
                })
            }
            setMask({ show: !1, text: '' })
        })
    }

    // 带看-新增-展示
    function beltAdd(e, type) {
        setBeltClient(e)
        setBeltType(type)
        setBelt({ show: !0 })
    }
    // 带看-员工编辑
    function beltStore(store_id, staff_id) {
        let newParam = { ...beltForm }
        newParam.store_id = store_id
        newParam.staff_id = staff_id
        setBeltForm(newParam)
    }
    // 带看-表单编辑
    function beltChange(name, value) {
        let newParam = { ...beltForm }
        newParam[name] = value
        setBeltForm(newParam)
    }
    // 带看-提交
    function beltConfirm() {
        let newForm = { ...beltForm }
        newForm.house_ids = houseSourceRef.current.map(e => e.id).join(',')
        newForm.type = beltType[0]
        newForm.guest_id = beltClient.id
        let url = newForm?.id ? 'client.belt.edit' : 'client.belt.add'
        http(url, { row: newForm }).then(res => {
            if (res.code === 1) {
                notification.success({
                    message: res.msg || '操作成功'
                })
                setBelt({ show: !1 })
            } else {
                notification.error({
                    message: res.msg || '操作失败，请重试'
                })
            }
        })
    }
    // 带看-表单重置
    function beltReset() {
        setHouseSource([])
        setBeltForm({})
    }
    // 带看-列表-展示
    function beltOpen(e, type) {
        setBeltClient(e)
        setBeltType(type)
        setBeltLog({ show: !0 })
    }
    // 带看-列表-数据
    function beltGet() {
        http('client.belt.index', {
            ...fieldGet(
                { guest_id: '=', type: '=' },
                { guest_id: beltClient.id, type: beltType[0] },
                beltLogPager.page,
                beltLogPager.pageSize
            )
        }).then(res => {
            if (res.code === 1) {
                setBeltLogSource(res.data.rows)
                setBeltLogTotal(res.data.total)
            }
        })
    }
    // 带看-编辑
    function beltEdit(ids) {
        http('client.belt.one', { ids }).then(res => {
            if (res.code === 1) {
                setBeltForm(res.data)
                setHouseSource(res.data.house_list)
                setBelt({ show: !0 })
            }
        })
    }
    // 带看-删除
    function beltDel(id) {
        let ids = id > 0 ? [id] : beltLogSelect
        http('client.belt.del', { ids }).then(res => {
            if (res.code === 1) {
                notification.success({
                    message: res.msg || '操作成功'
                })
            } else {
                notification.error({
                    message: res.msg || '操作失败，请重试'
                })
            }
            beltGet()
        })
    }

    // 添加房源-城市选择
    function houseCityChange(city, region, area) {
        let newForm = { ...houseForm }
        newForm.city = city
        newForm.region = region
        newForm.area = area
        setHouseForm(newForm)
    }
    // 添加房源-列表
    function houseGet() {
        let newParams = enSplit(houseForm, { price: ',' })
        http('house.index', {
            ...fieldGet(houseField, newParams, housePager.page, housePager.pageSize),
        }).then(res => {
            if (res.code === 1) {
                setHouseList(res.data.rows)
                setHouseTotal(res.data.total)
            }
        })
    }
    // 添加房源-重置
    function houseReset() {
        setHouseSelect([])
        setHouseForm({})
        setHousePager(pagerDefault)
    }
    // 添加房源-添加
    async function houseConfirm() {
        const res = await http('house.list', {
            ids: houseSelect.join(',')
        })
        if (res.code === 1) {
            let newList = [...houseSource, ...res.data]
            setHouseSource(newList)
            setHouse({ show: !1 })
            houseReset()
        } else {
            notification.error({
                message: res.msg || '操作失败，请重试'
            })
        }
    }
    // 添加房源-关闭
    function houseCancel() {
        houseReset()
        setHouse({ show: !1 })
    }
    // 添加房源-删除
    function houseDel(id) {
        let ind = houseSourceRef.current.findIndex(e => e.id === id)
        if (ind >= 0) {
            let newList = [...houseSourceRef.current]
            newList.splice(ind, 1)
            setHouseSource(newList)
        }
    }

    function followGet() {
        http('client.follow.index',
            fieldGet(
                { guest_id: followData.id },
                { guest_id: '=' },
                followMsgPager.page,
                followMsgPager.pageSize
            )
        ).then(res => {
            if (res.code === 1) {
                console.log(res);
                setFollowList(res.data.rows)
                setFollowMsgTotal(res.data.total)
            }
        }).catch((err) => console.log(err))
    }
    // 跟进-展示
    function followOpen(e) {
        setFollowData(e)
        setOpe({ show: !0 })
    }
    function followFormChange(name, value) {
        let newForm = JSON.parse(JSON.stringify(followForm))
        newForm[name] = value
        setFollowForm(newForm)
    }
    function followStaffChange(store_id, staff_id) {
        let newForm = JSON.parse(JSON.stringify(followForm))
        newForm.store_id = store_id
        newForm.staff_id = staff_id
        setFollowForm(newForm)
    }
    // 跟进-提交
    function followFormConfirm() {
        if (customer?.gjxz?.value ?? 0) {
            if (store.getState().userInfo.user_id !== followForm.follow_up_staff_id) return setjurisdiction(!0)
        }
        setMask({ show: !0, text: '请稍等...' })
        http('client.follow.add', {
            row: {
                guest_id: followData.id,
                ...followForm,
                images: fileList[0] ? fileList[0].response.data.url : ''
            }
        }).then(res => {
            if (res.code === 1) {
                notification.success({
                    message: res.msg || '操作成功'
                })
                setFollow({ show: !1 })
                followGet()
            } else {
                notification.error({
                    message: res.msg || '操作失败，请重试'
                })
            }
            setMask({ show: !1, text: '' })
        })
    }

    // 跟进-重置
    function followReset() {
        setFollowForm({})
        setFileList([])
    }

    // 表格右键的菜单栏
    function VisibleChange() {
        setisDropdown(!isDropdown)
        // if(!e) setisDropdown(false)
    }

    // 我的收藏
    function toggleCollect() {
        http('client.collect.ind').then(res => {
            if (res.code === 1) {
                const data = res.data.rows.map(i => i.guest_info)
                setSource(data)
            }
        }).catch(err => console.log(err))
    }

    // 收藏
    function collect(e) {
        let url, data
        if (e.guest_collect) {
            url = 'client.collect.del'
            data = {
                ids: e.guest_collect.id
            }
        } else {
            url = 'client.collect.add'
            data = {
                row: {
                    user_id: e.staff_id_1,
                    guest_id: e.id
                }
            }
        }
        http(url, data).then(res => {
            if (res.code === 1) {
                setchange(!1)
                clientGet()
            }
        }).catch(err => console.log(err))
    }

    // 保存通讯录搜索字段
    function paramcontacts(name, value, ind = null) {
        let newQuery = JSON.parse(JSON.stringify(staffSearch))
        if (ind !== null) {
            let arr = newQuery[name] || []
            arr[ind] = value
            newQuery[name] = arr
        } else if (name === 'birthday') {
            newQuery['s_birthday'] = value[0].split('-').join('')
            newQuery['e_birthday'] = value[1].split('-').join('')
        } else {
            newQuery[name] = value
        }
        console.log(newQuery);
        setstaffSearch(newQuery)
    }


    // 请求身份信息
    function getAllAuth() {
        http('auth.list').then(res => {
            console.log(res);
            if (res.code === 1) {
                setAllAuth(res.data.rows)
            }
        })
    }
    // 请求部门信息
    function getAllStore() {
        http('store.list').then(res => {
            if (res.code === 1) {
                setAllStore(res.data.rows)
            }
        })
    }

    function staffFind() {
        let pager = { ...staffPager }
        pager.size = 1
        setStaffPager(pager)
    }

    // 请求通讯录员工数据
    function staffGet() {
        http('user.index', {
            ...fieldGet(
                { name: 'like' },
                staffSearch,
                staffPager.page,
                staffPager.pageSize
            )
        }).then(res => {
            console.log(res);
            if (res.code === 1) {
                setcontactsSource(res.data.rows)
                setStaffTotal(res.data.total)
            }
        }).catch(err => console.log(err))
    }

    function changelist() {
        if (show) {
            setColumn(columnDefau)
        } else {
            setColumn(columnDefault)
        }
        console.log(column);
    }
}

export default Client;